The all-devices-app is a reference application demonstrating the Code-Driven Data Model within the Matter SDK. It implements a runtime-configurable data model.
This document describes the architectural layers, core classes, and design principles of the application.
The all-devices-app implements the Code-Driven Data Model:
provider.AddEndpoint(...) via CodeDrivenDataModelProvider.DefaultServerCluster (or similar code-driven base classes). Attributes and commands are strongly typed and encapsulated within the cluster classes.The all-devices-app enforces platform separation between core logic and target drivers:
graph TD A[Platform-Agnostic Core<br>`all-devices-common/`] B[POSIX Platform<br>`posix/`] C[ESP32 Platform<br>`esp32/`] D[SiLabs Platform<br>`silabs/`] E[Telink Platform<br>`telink/`] B -->|Instantiates & Overrides| A C -->|Instantiates & Overrides| A D -->|Instantiates & Overrides| A E -->|Instantiates & Overrides| A
all-devices-common/)Contains simulated device behaviors and capability management. This layer compiles independently of the operating system or hardware drivers. It includes:
devices/: Concrete implementations of simulated Matter devices (e.g., OccupancySensor, DimmableLight, Speaker).device-factory/: Registry (DeviceFactory) responsible for mapping CLI device names to creation factories.providers/: SDK-level data providers (such as AllDevicesExampleDeviceInfoProviderImpl) that supply node lifecycle information, storage interfaces, and descriptor details.posix/, esp32/, silabs/, telink/)These directories contain hardware-specific or OS-specific drivers, entrypoint main() functions, and build configurations.
DeviceFactoryPlatformOverride.cpp can register an LED driver for the on-off-light device instead of the simulated device.All devices in the application implement DeviceInterface and its core base class, SingleEndpointDevice.
classDiagram class DeviceInterface { <<interface>> +Register(EndpointId endpoint, CodeDrivenDataModelProvider & provider, EndpointId parentId)* CHIP_ERROR +Unregister(CodeDrivenDataModelProvider & provider)* +GetEndpointId() EndpointId +GetParentEndpointId() EndpointId } class SingleEndpointDevice { <<abstract>> -mEndpointId: EndpointId -mParentEndpointId: EndpointId -mDeviceTypeList: Span<DeviceTypeDescriptor> +Register(EndpointId endpoint, CodeDrivenDataModelProvider & provider, EndpointId parentId) CHIP_ERROR +Unregister(CodeDrivenDataModelProvider & provider) +SetEndpointId(EndpointId id) } class OccupancySensor { -mOccupancySensingCluster: OccupancySensingCluster -mBridgedDeviceBasicInformationCluster: BridgedDeviceBasicInformationCluster +Register(EndpointId endpoint, CodeDrivenDataModelProvider & provider, EndpointId parentId) CHIP_ERROR } DeviceInterface <|-- SingleEndpointDevice SingleEndpointDevice <|-- OccupancySensor
DeviceInterface (all-devices-common/devices/interface/DeviceInterface.h): Defines the pure virtual lifecycle contracts (Register, Unregister, etc.) required for registering a block of data model elements into the active server.SingleEndpointDevice (all-devices-common/devices/interface/SingleEndpointDevice.h): Encapsulates endpoint state, managing its assigned EndpointId, its parent endpoint relationship (for bridges or composite devices), and a list of DeviceTypeDescriptor structures.OccupancySensor): Inherit from SingleEndpointDevice, own one or more concrete strongly-typed cluster instances (LazyRegisteredServerCluster), and bind them to the endpoint during registration.The DeviceFactory singleton acts as the central device creator.
"occupancy-sensor") to creation callbacks.DeviceFactory::CreateDevice(...) to instantiate the specified runtime devices.When maintaining or extending the all-devices-app architecture, adhere to the following guidelines:
all-devices-common/. If a capability requires platform integration, define an interface in all-devices-common/ and provide the implementation in target directories (posix/, esp32/, etc.).DeviceInfoProvider or DeviceInstanceInfoProvider interfaces to handle non-volatile runtime variables and user settings.~Device() override = default; and manage lifecycle teardown explicitly by executing Unregister(provider).DeviceTypeParser.h, NetworkInfrastructureManager.h).