-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36b97e2
commit b9ac195
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...idl/matter_idl/tests/outputs/several_clusters/java/SecondClusterFabricDescriptorStruct.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* | ||
* 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 chip.tlv.AnonymousTag | ||
import chip.tlv.ContextSpecificTag | ||
import chip.tlv.Tag | ||
import chip.tlv.TlvParsingException | ||
import chip.tlv.TlvReader | ||
import chip.tlv.TlvWriter | ||
|
||
import java.util.Optional | ||
|
||
class SecondClusterFabricDescriptorStruct ( | ||
val rootPublicKey: ByteArray, | ||
val vendorID: Int, | ||
val fabricID: Long, | ||
val nodeID: Long, | ||
val label: String, | ||
val fabricIndex: Int) { | ||
override fun toString(): String = buildString { | ||
append("SecondClusterFabricDescriptorStruct {\n") | ||
append("\trootPublicKey : $rootPublicKey\n") | ||
append("\tvendorID : $vendorID\n") | ||
append("\tfabricID : $fabricID\n") | ||
append("\tnodeID : $nodeID\n") | ||
append("\tlabel : $label\n") | ||
append("\tfabricIndex : $fabricIndex\n") | ||
append("}\n") | ||
} | ||
|
||
fun toTlv(tag: Tag, tlvWriter: TlvWriter) { | ||
tlvWriter.apply { | ||
startStructure(tag) | ||
put(ContextSpecificTag(TAG_ROOT_PUBLIC_KEY), rootPublicKey) | ||
put(ContextSpecificTag(TAG_VENDOR_I_D), vendorID) | ||
put(ContextSpecificTag(TAG_FABRIC_I_D), fabricID) | ||
put(ContextSpecificTag(TAG_NODE_I_D), nodeID) | ||
put(ContextSpecificTag(TAG_LABEL), label) | ||
put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) | ||
endStructure() | ||
} | ||
} | ||
|
||
companion object { | ||
private const val TAG_ROOT_PUBLIC_KEY = 1 | ||
private const val TAG_VENDOR_I_D = 2 | ||
private const val TAG_FABRIC_I_D = 3 | ||
private const val TAG_NODE_I_D = 4 | ||
private const val TAG_LABEL = 5 | ||
private const val TAG_FABRIC_INDEX = 254 | ||
|
||
fun fromTlv(tag: Tag, tlvReader: TlvReader) : SecondClusterFabricDescriptorStruct { | ||
tlvReader.enterStructure(tag) | ||
val rootPublicKey = tlvReader.getByteArray(ContextSpecificTag(TAG_ROOT_PUBLIC_KEY)) | ||
val vendorID = tlvReader.getInt(ContextSpecificTag(TAG_VENDOR_I_D)) | ||
val fabricID = tlvReader.getLong(ContextSpecificTag(TAG_FABRIC_I_D)) | ||
val nodeID = tlvReader.getLong(ContextSpecificTag(TAG_NODE_I_D)) | ||
val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) | ||
val fabricIndex = tlvReader.getInt(ContextSpecificTag(TAG_FABRIC_INDEX)) | ||
|
||
tlvReader.exitContainer() | ||
|
||
return SecondClusterFabricDescriptorStruct(rootPublicKey, vendorID, fabricID, nodeID, label, fabricIndex) | ||
} | ||
} | ||
} |