Matter smart home protocol implementation for OCaml
OCaml 98.0%
Dune 0.6%
Other 1.4%
37 1 0

Clone this repository

https://tangled.org/gazagnaire.org/ocaml-matter https://tangled.org/did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-matter
git@git.recoil.org:gazagnaire.org/ocaml-matter git@git.recoil.org:did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-matter

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

matter#

Matter protocol implementation for OCaml.

Overview#

This library provides an implementation of the Matter smart home protocol as specified in the Matter Core Specification.

Features#

  • TLV (Tag-Length-Value) encoding and decoding
  • Support for all Matter TLV types: integers, booleans, floats, strings, bytes, null
  • Nested containers: structures, arrays, lists
  • All tag forms: anonymous, context-specific, common/implicit profile, fully-qualified

Installation#

opam install matter

Usage#

open Matter.Tlv

(* Create elements *)
let elem = structure [
  ctx_int 1 42;
  ctx_string 2 "hello";
  ctx_bool 3 true;
]

(* Encode to binary *)
let binary = encode_one elem

(* Decode from binary *)
match decode binary with
| Ok elements -> (* process elements *)
| Error msg -> (* handle error *)

API#

TLV Module#

  • Matter.Tlv.encode - Encode elements to binary TLV
  • Matter.Tlv.decode - Decode binary TLV to elements
  • Matter.Tlv.int, uint, bool, string, bytes, null - Value constructors
  • Matter.Tlv.structure, array, list - Container constructors
  • Matter.Tlv.ctx_int, ctx_uint, etc. - Context-tagged constructors

Licence#

MIT License. See LICENSE.md for details.