Skip to content

Commit

Permalink
Adding missing kotlin files
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs committed Dec 14, 2023
1 parent ac245f7 commit 339a9b6
Show file tree
Hide file tree
Showing 7 changed files with 1,934 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package chip.devicecontroller.cluster.structs

import chip.devicecontroller.cluster.*
import matter.tlv.ContextSpecificTag
import matter.tlv.Tag
import matter.tlv.TlvReader
import matter.tlv.TlvWriter

class MatterScenesClusterAttributeValuePair(val attributeID: ULong, val attributeValue: ULong) {
override fun toString(): String = buildString {
append("MatterScenesClusterAttributeValuePair {\n")
append("\tattributeID : $attributeID\n")
append("\tattributeValue : $attributeValue\n")
append("}\n")
}

fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
tlvWriter.apply {
startStructure(tlvTag)
put(ContextSpecificTag(TAG_ATTRIBUTE_I_D), attributeID)
put(ContextSpecificTag(TAG_ATTRIBUTE_VALUE), attributeValue)
endStructure()
}
}

companion object {
private const val TAG_ATTRIBUTE_I_D = 0
private const val TAG_ATTRIBUTE_VALUE = 1

fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MatterScenesClusterAttributeValuePair {
tlvReader.enterStructure(tlvTag)
val attributeID = tlvReader.getULong(ContextSpecificTag(TAG_ATTRIBUTE_I_D))
val attributeValue = tlvReader.getULong(ContextSpecificTag(TAG_ATTRIBUTE_VALUE))

tlvReader.exitContainer()

return MatterScenesClusterAttributeValuePair(attributeID, attributeValue)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package chip.devicecontroller.cluster.structs

import chip.devicecontroller.cluster.*
import matter.tlv.AnonymousTag
import matter.tlv.ContextSpecificTag
import matter.tlv.Tag
import matter.tlv.TlvReader
import matter.tlv.TlvWriter

class MatterScenesClusterExtensionFieldSet(
val clusterID: ULong,
val attributeValueList: List<MatterScenesClusterAttributeValuePair>
) {
override fun toString(): String = buildString {
append("MatterScenesClusterExtensionFieldSet {\n")
append("\tclusterID : $clusterID\n")
append("\tattributeValueList : $attributeValueList\n")
append("}\n")
}

fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
tlvWriter.apply {
startStructure(tlvTag)
put(ContextSpecificTag(TAG_CLUSTER_I_D), clusterID)
startArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST))
for (item in attributeValueList.iterator()) {
item.toTlv(AnonymousTag, this)
}
endArray()
endStructure()
}
}

companion object {
private const val TAG_CLUSTER_I_D = 0
private const val TAG_ATTRIBUTE_VALUE_LIST = 1

fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MatterScenesClusterExtensionFieldSet {
tlvReader.enterStructure(tlvTag)
val clusterID = tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER_I_D))
val attributeValueList =
buildList<MatterScenesClusterAttributeValuePair> {
tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST))
while (!tlvReader.isEndOfContainer()) {
add(MatterScenesClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader))
}
tlvReader.exitContainer()
}

tlvReader.exitContainer()

return MatterScenesClusterExtensionFieldSet(clusterID, attributeValueList)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package chip.devicecontroller.cluster.structs

import chip.devicecontroller.cluster.*
import matter.tlv.ContextSpecificTag
import matter.tlv.Tag
import matter.tlv.TlvReader
import matter.tlv.TlvWriter

class MatterScenesClusterSceneInfoStruct(
val sceneCount: UInt,
val currentScene: UInt,
val currentGroup: UInt,
val sceneValid: Boolean,
val remainingCapacity: UInt,
val fabricIndex: UInt
) {
override fun toString(): String = buildString {
append("MatterScenesClusterSceneInfoStruct {\n")
append("\tsceneCount : $sceneCount\n")
append("\tcurrentScene : $currentScene\n")
append("\tcurrentGroup : $currentGroup\n")
append("\tsceneValid : $sceneValid\n")
append("\tremainingCapacity : $remainingCapacity\n")
append("\tfabricIndex : $fabricIndex\n")
append("}\n")
}

fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
tlvWriter.apply {
startStructure(tlvTag)
put(ContextSpecificTag(TAG_SCENE_COUNT), sceneCount)
put(ContextSpecificTag(TAG_CURRENT_SCENE), currentScene)
put(ContextSpecificTag(TAG_CURRENT_GROUP), currentGroup)
put(ContextSpecificTag(TAG_SCENE_VALID), sceneValid)
put(ContextSpecificTag(TAG_REMAINING_CAPACITY), remainingCapacity)
put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex)
endStructure()
}
}

companion object {
private const val TAG_SCENE_COUNT = 0
private const val TAG_CURRENT_SCENE = 1
private const val TAG_CURRENT_GROUP = 2
private const val TAG_SCENE_VALID = 3
private const val TAG_REMAINING_CAPACITY = 4
private const val TAG_FABRIC_INDEX = 254

fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MatterScenesClusterSceneInfoStruct {
tlvReader.enterStructure(tlvTag)
val sceneCount = tlvReader.getUInt(ContextSpecificTag(TAG_SCENE_COUNT))
val currentScene = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_SCENE))
val currentGroup = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_GROUP))
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 MatterScenesClusterSceneInfoStruct(
sceneCount,
currentScene,
currentGroup,
sceneValid,
remainingCapacity,
fabricIndex
)
}
}
}
Loading

0 comments on commit 339a9b6

Please sign in to comment.