Matter Data Types¶
This is the base type of the DataType classes. It is abstract and not instantiable itself, and contains no functionality but defines the interface.
- class st.matter.data_types.DataType¶
- Abstract:
A generic class defining the interface shared across all Matter data types
- NAME: str¶
pretty print class name
- ID: number¶
the Matter data type ID for this data type
- serialize()¶
Pack this DataType
- Returns:
the byte representation of this DataType length of byte_length
- Return type:
str
- static deserialize(bytes, field_name)¶
Parse this DataType from a string of bytes
- Parameters:
bytes (
str) – the bytes containing the st.matter.data_types.DataType only byte_length bytes will be consumed extra will be ignoredfield_name (
str) – optional name of this field (used when pretty_printing)
- Returns:
the parsed version of DataType
- Return type:
- get_length()¶
Get the length in bytes of this DataType
- Returns:
the byte length of this DataType
- Return type:
number
- pretty_print()¶
Format this DataType in a human readable way
- Returns:
A human readable string of this DataType
- Return type:
str
Null¶
- class st.matter.data_types.NullABC: st.matter.data_types.DataType¶
Classes being created using the NullABC class represent Matter data types whose lua “value” is stored as nil.
- static new_mt(base)¶
This function will create a new metatable with the appropriate functionality for a Matter Null
- class st.matter.data_types.Null: st.matter.data_types.NullABC¶
- ID: number¶
0x00
- NAME: str¶
“Null”
- value: nil¶
this data type has no body
Data¶
- class st.matter.data_types.DataABC: st.matter.data_types.DataType¶
Classes being created using the DataABC class represent Matter data types whose lua “value” is stored as a generic byte string as the direct structure is not known or not storable in another way. In general these are the Matter data types Data8-Data64 represented by IDs 0x08-0x0F. However, due to limitations of lua numbers, numeric types of 64 bit length use this base as well.
- static new_mt(base, byte_length)¶
This function will create a new metatable with the appropriate functionality for a Matter Data field
- Parameters:
base (
table) – the base meta table, this will include the ID and NAME of the type being representedbyte_length (
number) – the length in bytes of this Data field
- class st.matter.data_types.Int64: st.matter.data_types.IntABC¶
- ID: number¶
0x03
- NAME: str¶
“Int64”
- byte_length: number¶
8
- value: number¶
This is the actual value of the instance of the data type
- class st.matter.data_types.Uint64: st.matter.data_types.UintABC¶
Note that very large numbers may require definition through hex or negative integers. This is because Lua
interprets all integers as signed, so numbers above (2 ^ 63) - 1 will be interpreted as negative. However, this is a two’s complement representation, and so we can still store those numbers losslessly.
- ID: number¶
0x07
- NAME: str¶
“Uint64”
- byte_length: number¶
8
- value: number¶
This is the actual value of the instance of the data type
Boolean¶
- class st.matter.data_types.BooleanABC: st.matter.data_types.DataType¶
Classes being created using the BooleanABC class represent Matter data types whose lua “value” is stored as a boolean.
- static new_mt(base)¶
This function will create a new metatable with the appropriate functionality for a Matter Boolean
Bitmap and Enum¶
Bitmaps and Enum values are represented as unsigned integers
Uint¶
- class st.matter.data_types.UintABC: st.matter.data_types.DataType¶
Classes being created using the UintABC class represent Matter data types whose lua “value” is stored as an unsigned number. In general these are the Matter data types Uint8-Uint56 represented by IDs 0x20-0x26. Uint64 has to be treated differently due to lua limitations. In addition there are several other ID types that derive their behavior from Uint as well.
- class st.matter.data_types.Uint8: st.matter.data_types.UintABC¶
- ID: number¶
0x04
- NAME: str¶
“Uint8”
- byte_length: number¶
1
- value: number¶
This is the actual value of the instance of the data type
Int¶
- class st.matter.data_types.IntABC: st.matter.data_types.DataType¶
Classes being created using the IntABC class represent Matter data types whose lua “value” is stored as a signed number. In general these are the Matter data types Int8-Int56 represented by IDs 0x28-0x2E. Int64 has to be treated differently due to lua limitations.
- class st.matter.data_types.Int8: st.matter.data_types.IntABC¶
- ID: number¶
0x00
- NAME: str¶
“Int8”
- byte_length: number¶
1
- value: number¶
This is the actual value of the instance of the data type
Floating Points¶
- class st.matter.data_types.FloatABC: st.matter.data_types.DataType¶
This represents a number of the form (1 + mantissa) * 2 ^ exponent with some exceptions see the Matter spec for further details
- mantissa: number¶
The fractional component of the number
- exponent: number¶
The exponent for 2
- sign: number¶
either 1 if the value is negative or 0 if positive
- static new_mt(base, byte_length, mantissa_bit_length, exponent_bit_length)¶
This function will create a new metatable with the appropriate functionality for a Matter Float field
- Parameters:
base (
table) – the base meta table, this will include the ID and NAME of the type being representedbyte_length (
number) – the length in bytes of this Float fieldmantissa_bit_length (
number) – the number of bits to use for the mantissa fieldexponent_bit_length (
number) – the number of bits to use for the exponent field
Strings¶
- class st.matter.data_types.StringABC: st.matter.data_types.DataType¶
Classes being created using the StringABC class represent Matter data types whose lua “value” is stored as a string. These are the Matter data types UTF-8 String, 1-octet length, UTF-8 String, 2-octet length, UTF-8 String, 4-octet length, and UTF-8 String, 8-octet length.
- static new_mt(base, length_byte_length)¶
This function will create a new metatable with the appropriate functionality for a Matter String
- Parameters:
base (
table) – the base meta table, this will include the ID and NAME of the type being representedlength_byte_length (
number) – the length of the encoded byte_length of this String
- class st.matter.data_types.OctetString1: st.matter.data_types.StringABC¶
- ID: number¶
0x10
- NAME: str¶
“OctetString1”
- length_byte_length: number¶
1 (This is the number of bytes the length description takes)
- byte_length: number¶
the length of this string (not including the length bytes)
- value: str¶
The string representation of this field (note this does not include the length bytes)
- class st.matter.data_types.OctetString2: st.matter.data_types.StringABC¶
- ID: number¶
0x11
- NAME: str¶
“OctetString2”
- length_byte_length: number¶
1 (This is the number of bytes the length description takes)
- byte_length: number¶
the length of this string (not including the length bytes)
- value: str¶
The string representation of this field (note this does not include the length bytes)
- class st.matter.data_types.OctetString4: st.matter.data_types.StringABC¶
- ID: number¶
0x12
- NAME: str¶
“OctetString4”
- length_byte_length: number¶
1 (This is the number of bytes the length description takes)
- byte_length: number¶
the length of this string (not including the length bytes)
- value: str¶
The string representation of this field (note this does not include the length bytes)
- class st.matter.data_types.OctetString8: st.matter.data_types.StringABC¶
- ID: number¶
0x13
- NAME: str¶
“OctetString8”
- length_byte_length: number¶
1 (This is the number of bytes the length description takes)
- byte_length: number¶
the length of this string (not including the length bytes)
- value: str¶
The string representation of this field (note this does not include the length bytes)
- class st.matter.data_types.UTF8String1: st.matter.data_types.StringABC¶
- ID: number¶
0x0C
- NAME: str¶
“UTF8String1”
- length_byte_length: number¶
1 (This is the number of bytes the length description takes)
- byte_length: number¶
the length of this string (not including the length bytes)
- value: str¶
The string representation of this field (note this does not include the length bytes)
- class st.matter.data_types.UTF8String2: st.matter.data_types.StringABC¶
- ID: number¶
0x0D
- NAME: str¶
“UTF8String2”
- length_byte_length: number¶
2 (This is the number of bytes the length description takes)
- byte_length: number¶
the length of this string (not including the length bytes)
- value: str¶
The string representation of this field (note this does not include the length bytes)
- class st.matter.data_types.UTF8String4: st.matter.data_types.StringABC¶
- ID: number¶
0x0E
- NAME: str¶
“UTF8String4”
- length_byte_length: number¶
4 (This is the number of bytes the length description takes)
- byte_length: number¶
the length of this string (not including the length bytes)
- value: str¶
The string representation of this field (note this does not include the length bytes)
- class st.matter.data_types.UTF8String8: st.matter.data_types.StringABC¶
- ID: number¶
0x0F
- NAME: str¶
“UTF8String8”
- length_byte_length: number¶
8 (This is the number of bytes the length description takes)
- byte_length: number¶
the length of this string (not including the length bytes)
- value: str¶
The string representation of this field (note this does not include the length bytes)
Container Types¶
- class st.matter.data_types.ArrayABC: st.matter.data_types.DataType¶
Classes being created using the ArrayABC class represent Matter data types whose lua “value” is stored as a Lua-native 1-indexed table of Matter data types all of the same type.
- static new_mt(base)¶
This function will create a new metatable with the appropriate functionality for a Matter Array
- class st.matter.data_types.Array: st.matter.data_types.ArrayABC¶
- ID: number¶
0x16 (aka Matter Element Type)
- NAME: str¶
“Array”
- value: table¶
the list of elements in this array
- class st.matter.data_types.StructureABC: st.matter.data_types.DataType¶
Classes being created using the StructureABC class represent matter data types whose lua “value” is stored as an array of matter data types each of which can be a separate type.
- static new_mt(base)¶
This function will create a new metatable with the appropriate functionality for a matter Structure
- class st.matter.data_types.Structure: st.matter.data_types.StructureABC¶
- ID: number¶
0x15
- NAME: str¶
“Structure”
- elements: table¶
the list of elements in this structure