circuitmatter.tlv

Attributes

TAG_LENGTH

INT_SIZE

Exceptions

ArrayEncodingError

Common base class for all non-exit exceptions.

Classes

ElementType

Enum where members are also (and must be) ints

Container

Structure

Member

Helper class that provides a standard way to create an ABC using

NumberMember

Helper class that provides a standard way to create an ABC using

IntMember

Helper class that provides a standard way to create an ABC using

EnumMember

Helper class that provides a standard way to create an ABC using

BitmapMember

Helper class that provides a standard way to create an ABC using

FloatMember

Helper class that provides a standard way to create an ABC using

BoolMember

Helper class that provides a standard way to create an ABC using

StringMember

Helper class that provides a standard way to create an ABC using

OctetStringMember

Helper class that provides a standard way to create an ABC using

UTF8StringMember

Helper class that provides a standard way to create an ABC using

StructMember

Helper class that provides a standard way to create an ABC using

ArrayMember

Helper class that provides a standard way to create an ABC using

List

ListMember

Helper class that provides a standard way to create an ABC using

AnythingMember

Stores a TLV encoded value.

Functions

decode_tag(control_octet, buffer[, offset])

decode_element(control_octet, buffer, offset, depth)

Module Contents

circuitmatter.tlv.TAG_LENGTH = b'\x00\x01\x02\x04\x02\x04\x06\x08'
circuitmatter.tlv.INT_SIZE = 'BHIQ'
class circuitmatter.tlv.ElementType

Bases: enum.IntEnum

Enum where members are also (and must be) ints

SIGNED_INT = 0
UNSIGNED_INT = 4
BOOL = 8
FLOAT = 10
UTF8_STRING = 12
OCTET_STRING = 16
NULL = 20
STRUCTURE = 21
ARRAY = 22
LIST = 23
END_OF_CONTAINER = 24
circuitmatter.tlv.decode_tag(control_octet, buffer, offset=0)
circuitmatter.tlv.decode_element(control_octet, buffer, offset, depth)
class circuitmatter.tlv.Container
values
classmethod max_length()
set_value(tag, value)
delete_value(tag)
class circuitmatter.tlv.Structure

Bases: Container

__str__()
encode() memoryview
encode_into(buffer: bytearray, offset: int = 0) int
classmethod decode(buffer: memoryview, offset=0) Structure
classmethod decode_member(control_octet, buffer, offset=0, depth=0) tuple[dict, int]
construct_containers()
classmethod from_value(value)
values
classmethod max_length()
set_value(tag, value)
delete_value(tag)
class circuitmatter.tlv.Member(tag, *, optional: _OPT = False, nullable: _NULLABLE = False, default=None)

Bases: abc.ABC, Generic[_T, _OPT, _NULLABLE]

Helper class that provides a standard way to create an ABC using inheritance.

max_value_length: int = 0
tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__set__(obj: Structure, value: _T | None) None
__set__(obj: Structure, value: _T) None
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

abstract decode_member(control_octet: int, buffer: memoryview, offset: int = 0)

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

abstract encode_element_type(value: _T) int

Return Element Type Field as defined in Appendix A in the spec

abstract encode_value_into(value: _T | None, buffer: bytearray, offset: int) int
abstract encode_value_into(value: _T, buffer: bytearray, offset: int) int

Encode value into buffer and return the new offset

abstract print(value: _T) str

Return string representation of value

from_value(value)
__slots__ = ()
class circuitmatter.tlv.NumberMember(tag, _format: str, optional: _OPT = False, nullable: _NULLABLE = False, minimum: int | None = None, maximum: int | None = None, **kwargs)

Bases: Member[_NT, _OPT, _NULLABLE], Generic[_NT, _OPT, _NULLABLE]

Helper class that provides a standard way to create an ABC using inheritance.

format
integer
signed
max_value_length
__set__(obj, value)
static decode_member(control_octet, buffer, offset=0, depth=0) tuple[_NT, int]

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

print(value)

Return string representation of value

encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer, offset) int

Encode value into buffer and return the new offset

tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()
class circuitmatter.tlv.IntMember(tag, *, signed: bool = True, octets: Literal[1, 2, 4, 8] = 1, optional: _OPT = False, nullable: _NULLABLE = False, **kwargs)

Bases: NumberMember[int, _OPT, _NULLABLE]

Helper class that provides a standard way to create an ABC using inheritance.

uformat
format
integer
signed
max_value_length
__set__(obj, value)
static decode_member(control_octet, buffer, offset=0, depth=0) tuple[_NT, int]

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

print(value)

Return string representation of value

encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer, offset) int

Encode value into buffer and return the new offset

tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()
class circuitmatter.tlv.EnumMember(tag, enum_class, **kwargs)

Bases: IntMember

Helper class that provides a standard way to create an ABC using inheritance.

enum_class
__set__(obj, value)
__get__(obj, objtype=None) enum.Enum | None
print(value)

Return string representation of value

uformat
format
integer
signed
max_value_length
static decode_member(control_octet, buffer, offset=0, depth=0) tuple[_NT, int]

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer, offset) int

Encode value into buffer and return the new offset

tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()
class circuitmatter.tlv.BitmapMember(tag, enum_class, **kwargs)

Bases: EnumMember

Helper class that provides a standard way to create an ABC using inheritance.

print(value)

Return string representation of value

enum_class
__set__(obj, value)
__get__(obj, objtype=None) enum.Enum | None
uformat
format
integer
signed
max_value_length
static decode_member(control_octet, buffer, offset=0, depth=0) tuple[_NT, int]

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer, offset) int

Encode value into buffer and return the new offset

tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()
class circuitmatter.tlv.FloatMember(tag, *, octets: Literal[4, 8] = 4, optional: _OPT = False, nullable: _NULLABLE = False, **kwargs)

Bases: NumberMember[float, _OPT, _NULLABLE]

Helper class that provides a standard way to create an ABC using inheritance.

format
integer
signed
max_value_length
__set__(obj, value)
static decode_member(control_octet, buffer, offset=0, depth=0) tuple[_NT, int]

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

print(value)

Return string representation of value

encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer, offset) int

Encode value into buffer and return the new offset

tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()
class circuitmatter.tlv.BoolMember(tag, *, optional: _OPT = False, nullable: _NULLABLE = False, default=None)

Bases: Member[bool, _OPT, _NULLABLE]

Helper class that provides a standard way to create an ABC using inheritance.

max_value_length = 0
static decode_member(control_octet, buffer, offset=0, depth=0)

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

print(value)

Return string representation of value

encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer, offset) int

Encode value into buffer and return the new offset

tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__set__(obj: Structure, value: _T | None) None
__set__(obj: Structure, value: _T) None
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()
class circuitmatter.tlv.StringMember(tag, max_length: int, *, optional: _OPT = False, nullable: _NULLABLE = False, min_length: int = 0, **kwargs)

Bases: Member[AnyStr, _OPT, _NULLABLE], Generic[AnyStr, _OPT, _NULLABLE]

Helper class that provides a standard way to create an ABC using inheritance.

max_length_encoding
max_length_format
length_length
min_length
max_value_length
print(value)

Return string representation of value

__set__(obj, value)
encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer: bytearray, offset: int) int

Encode value into buffer and return the new offset

static parse_length(control_octet, buffer, offset=0)
tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

abstract decode_member(control_octet: int, buffer: memoryview, offset: int = 0)

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

from_value(value)
__slots__ = ()
class circuitmatter.tlv.OctetStringMember(tag, max_length: int, *, optional: _OPT = False, nullable: _NULLABLE = False, min_length: int = 0, **kwargs)

Bases: StringMember[bytes, _OPT, _NULLABLE]

Helper class that provides a standard way to create an ABC using inheritance.

static decode_member(control_octet, buffer, offset=0, depth=0)

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

max_length_encoding
max_length_format
length_length
min_length
max_value_length
print(value)

Return string representation of value

__set__(obj, value)
encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer: bytearray, offset: int) int

Encode value into buffer and return the new offset

static parse_length(control_octet, buffer, offset=0)
tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()
class circuitmatter.tlv.UTF8StringMember(tag, max_length: int, *, optional: _OPT = False, nullable: _NULLABLE = False, min_length: int = 0, **kwargs)

Bases: StringMember[str, _OPT, _NULLABLE]

Helper class that provides a standard way to create an ABC using inheritance.

static decode_member(control_octet, buffer, offset=0, depth=0)

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

encode_value_into(value: str, buffer, offset) int

Encode value into buffer and return the new offset

print(value)

Return string representation of value

max_length_encoding
max_length_format
length_length
min_length
max_value_length
__set__(obj, value)
encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

static parse_length(control_octet, buffer, offset=0)
tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()
class circuitmatter.tlv.StructMember(tag, substruct_class: type[_TLVStruct], *, optional: _OPT = False, nullable: _NULLABLE = False, **kwargs)

Bases: Member[_TLVStruct, _OPT, _NULLABLE]

Helper class that provides a standard way to create an ABC using inheritance.

substruct_class
max_value_length
static decode_member(control_octet, buffer, offset=0, depth=0)

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

print(value)

Return string representation of value

encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer: bytearray, offset: int) int

Encode value into buffer and return the new offset

tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__set__(obj: Structure, value: _T | None) None
__set__(obj: Structure, value: _T) None
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()
exception circuitmatter.tlv.ArrayEncodingError(index, offset)

Bases: Exception

Common base class for all non-exit exceptions.

index

First index not encoded

offset
class circuitmatter.tlv.ArrayMember(tag, substruct_class: type[_TLVStruct, Member], *, max_length: int | None = None, optional: _OPT = False, nullable: _NULLABLE = False, **kwargs)

Bases: Member[_TLVStruct, _OPT, _NULLABLE]

Helper class that provides a standard way to create an ABC using inheritance.

substruct_class
max_value_length = 1280
max_items
static decode_member(control_octet, buffer, offset=0, depth=0)

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

print(value)

Return string representation of value

encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer: memoryview, offset: int) int

Encode value into buffer and return the new offset

tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__set__(obj: Structure, value: _T | None) None
__set__(obj: Structure, value: _T) None
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()
class circuitmatter.tlv.List

Bases: Container

items = []
values
__iter__()
__str__()
encode() memoryview
encode_into(buffer: bytearray, offset: int = 0) int
classmethod from_value(value)
set_value(tag, value)
delete_value(tag)
copy()
classmethod max_length()
class circuitmatter.tlv.ListMember(tag, substruct_class: type[_TLVList], *, optional: _OPT = False, nullable: _NULLABLE = False, **kwargs)

Bases: Member

Helper class that provides a standard way to create an ABC using inheritance.

substruct_class
max_value_length
static decode_member(control_octet, buffer, offset=0, depth=0)

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

print(value)

Return string representation of value

encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer: bytearray, offset: int) int

Encode value into buffer and return the new offset

tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__set__(obj: Structure, value: _T | None) None
__set__(obj: Structure, value: _T) None
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()
class circuitmatter.tlv.AnythingMember(tag, *, optional: _OPT = False, nullable: _NULLABLE = False, default=None)

Bases: Member

Stores a TLV encoded value.

decode_member(control_octet, buffer, offset=0)

Return the decoded value at offset in buffer. offset is after the tag (but before any length)

print(value)

Return string representation of value

encode_element_type(value)

Return Element Type Field as defined in Appendix A in the spec

encode_value_into(value, buffer: bytearray, offset: int) int

Encode value into buffer and return the new offset

max_value_length: int = 0
tag
optional
nullable
tag_length = 0
__set_name__(owner, name)
property max_length
__get__(obj: Structure, objtype: type[Structure] | None = None) _T | None
__get__(obj: Structure, objtype: type[Structure] | None = None) _T
__set__(obj: Structure, value: _T | None) None
__set__(obj: Structure, value: _T) None
__delete__(obj)
encode(value)
encode_into(obj: Container, buffer: bytearray | memoryview, offset: int, anonymous_ok=False) int
decode(buffer: memoryview, offset: int = 0) _T

Return the decoded value at offset in buffer

from_value(value)
__slots__ = ()