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

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 ignored

  • field_name (str) – optional name of this field (used when pretty_printing)

Returns

the parsed version of DataType

Return type

st.matter.data_types.DataType

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

Parameters

base (table) – the base meta table, this will include the ID and NAME of the type being represented

Returns

The meta table containing the functionality for this type class

Return type

table

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 represented

  • byte_length (number) – the length in bytes of this Data field

class st.matter.data_types.Int64: st.matter.data_types.DataABC

64 bits long and signed. In this case our number is signed so we could possibly use a native number However, to maintain consistency with all other 64 bit Matter types we actually inherit from the DataABC Matter type and store the bytes of the number directly. Thus usage of this will be different.

ID: number

0x03

NAME: str

“Int64”

byte_length: number

8

value: str

This is the actual value of the instance of the data type

class st.matter.data_types.Uint64: st.matter.data_types.DataABC

64 bits long and unsigned. We inherit from the DataABC matter type and store the bytes of the number directly. Thus usage of this will be different

ID: number

0x07

NAME: str

“Uint64”

byte_length: number

8

value: str

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

Parameters

base (table) – the base meta table, this will include the ID and NAME of the type being represented

Returns

The meta table containing the functionality for this type class

Return type

table

class st.matter.data_types.Boolean: st.matter.data_types.BooleanABC
ID: number

0x08

ExtendedID: number

0x09 allows too element types to map to the same data type

NAME: str

“Boolean”

value: boolean

The value of this boolean data type

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.

static new_mt(base, byte_length)

This function will create a new metatable with the appropriate functionality for a Matter Uint

Parameters
  • base (table) – the base meta table, this will include the ID and NAME of the type being represented

  • byte_length (number) – the length in bytes of this Uint

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

class st.matter.data_types.Uint16: st.matter.data_types.UintABC
ID: number

0x05

NAME: str

“Uint16”

byte_length: number

2

value: number

This is the actual value of the instance of the data type

class st.matter.data_types.Uint32: st.matter.data_types.UintABC
ID: number

0x06

NAME: str

“Uint32”

byte_length: number

4

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.

static new_mt(base, byte_length)

This function will create a new metatable with the appropriate functionality for a Matter Int

Parameters
  • base (table) – the base meta table, this will include the ID and NAME of the type being represented

  • byte_length (number) – the length in bytes of this Int

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

class st.matter.data_types.Int16: st.matter.data_types.IntABC
ID: number

0x01

NAME: str

“Int16”

byte_length: number

1

value: number

This is the actual value of the instance of the data type

class st.matter.data_types.Int32: st.matter.data_types.IntABC
ID: number

0x02

NAME: str

“Int32”

byte_length: number

4

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 represented

  • byte_length (number) – the length in bytes of this Float field

  • mantissa_bit_length (number) – the number of bits to use for the mantissa field

  • exponent_bit_length (number) – the number of bits to use for the exponent field

class st.matter.data_types.SinglePrecisionFloat: st.matter.data_types.FloatABC
ID: number

0x0A

NAME: str

“SinglePrecision”

byte_length: number

4

mantissa_bit_length: number

23

exponent_bit_length: number

8

class st.matter.data_types.DoublePrecisionFloat: st.matter.data_types.FloatABC
ID: number

0x0B

NAME: str

“DoublePrecision”

byte_length: number

8

mantissa_bit_length: number

52

exponent_bit_length: number

11

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 represented

  • length_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

Parameters

base (table) – the base meta table, this will include the ID and NAME of the type being represented

Returns

The meta table containing the functionality for this type class

Return type

table

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

Parameters

base (table) – the base meta table, this will include the ID and NAME of the type being represented

Returns

The meta table containing the functionality for this type class

Return type

table

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