Matter Device Types Catalog#
This directory contains C++ representations of spec-defined Matter Device Types (e.g., OnOff Light, Dimmable Light, Laundry Washer, Aggregator).
Directory Structure & Inheritance#
Every directory under device/types/<foo>/ separates the generic Matter Device
Type definition from concrete simulation or hardware implementations:
device/types/foo/
├── Foo.h / Foo.cpp # Generic base device class (mandatory spec clusters only)
├── OOBAccessors.h / .cpp # Out-of-Band control & inspection accessors
├── NamedPipeTranslators.h / .cpp # JSON CLI command translators
└── impl/
└── LoggingFoo.h / .cpp # Self-contained simulation subclass for DeviceFactory
Strict Inheritance Direction#
impl/LoggingFoo (Simulation) -> Foo (Base Device Type) -> SingleEndpoint
Base Device Type (
Foo.h):Inherits directly from
SingleEndpoint(or a shared capability in special cases).Defines the Matter
DeviceTypeEntry(Device Type ID and revision).Owns only mandatory clusters for that device type and accepts abstract
Delegate &references in its constructor.Contains zero simulation, logging, or hardware pin logic.
Concrete Implementation (
impl/LoggingFoo.horEmulatedFoo.h):Inherits from
Foo(device_type), never the reverse.Implements cluster delegates (inheriting privately from delegate bases before
public Foofor base-from-member initialization safety).Instantiated by
DeviceFactoryfor simulations; hardware targets subclassFoowith hardware drivers.
Design Rules#
Spec Compliance & Naming: Class and folder names correspond directly to Matter Device Library Specification names without the
Devicesuffix (e.g.,LaundryWasher, notLaundryWasherDevice).Optional Clusters via Extension Hooks: Do not place optional clusters in the base
Fooclass. BecauseCodeDrivenDataModelProviderrequires all clusters on an endpoint to be added beforeprovider.AddEndpoint()is called, base classes expose virtual hooks insideRegister()andUnregister():RegisterAdditionalClusters(EndpointId, CodeDrivenDataModelProvider &)UnregisterAdditionalClusters(CodeDrivenDataModelProvider &)Subclasses inimpl/override these hooks to attach optional clusters.
Prefer Direct
SingleEndpointInheritance: Avoid creating new shared endpoint base classes indevice/capabilities/. Prefer flat, self-contained device classes inheriting fromSingleEndpoint, sharing delegate helper mixins inimpl/when needed.