2 # Copyright (c) 2021 Project CHIP Authors
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 # Contains type definition to help with thread credentials.
18 # Generally thread credentials are assumed to be binary objects, however for
19 # testing purposes, we expose the internal structure here.
21 from construct import BitStruct, Byte, Bytes, Enum, Flag, Int16ul, Int32ul, Int64ul, PaddedString, Padding, Struct
23 ThreadDeviceNetworkInfo = Struct(
24 "NetworkId" / Int32ul,
25 "FieldPresent" / BitStruct (
27 "ThreadExtendedPANId" / Flag,
28 "ThreadMeshPrefix" / Flag,
30 "Padding" / Padding(4),
32 "WiFiSSID" / PaddedString(33, 'utf8'),
33 "WiFikey" / Bytes(64),
35 "WiFiAuthSecurityType" / Enum(Byte,
36 # NotAvailable is the same as None/NotSpecified in DeviceNetworkInfo.h
37 # Used this name because 'None' is reserved in python
42 WPA2MixedPersonal = 5,
45 WPA2MixedEnterprise = 8,
47 WPA3MixedPersonal = 10,
49 WPA3MixedEnterprise = 12,
51 "ThreadNetworkName" / PaddedString(17, 'utf8'),
52 "ThreadExtendedPANId" / Bytes(8),
53 "ThreadMeshPrefix" / Bytes(8),
54 "ThreadMasterKey" / Bytes(16),
55 "ThreadPSKc" / Bytes(16),
56 "_ThreadPANIdPadding" / Padding(1), # Aligns ThreadPANId
57 "ThreadPANId" / Int16ul,
58 "ThreadChannel" / Byte,
59 "_ThreadDatasetTimestampPadding" / Padding(3), # Aligns ThreadDAtasetTimestamp
60 "ThreadDatasetTimestamp" / Int64ul,