Old Macdonald - Decentralised Controlled Environment Agriculture System Help

Matter Interface

Overview

The Matter Interface is a part of the Orchestrator firmware.

This component initializes the Matter stack, including CHIP memory, the OTA requestor, default providers, and the event loop.

It also provides initialization for the Matter controller client with optional commissioner support.

Development

Pre-requisites:

Bootstrap Component

The command below creates a new component named matter_controller_interface inside the components directory.

idf.py create-component matter_controller_interface -C components

Change the file extension of the matter_controller_interface.c file to matter_controller_interface.cpp and move it to the src folder.

mv components/matter_controller_interface/matter_controller_interface.c components/matter_controller_interface/src/matter_controller_interface.cpp

Matter Initialization

The esp_matter::start() function in esp_matter_core.cpp sets up the Matter stack and creates the default event loop by calling esp_event_loop_create_default, which is shared across the system. As part of this initialization, ESP-Netif is also brought up automatically through the ESP32-specific PlatformManagerImpl, which connects the Matter stack to platform features like networking and timers. Wi-Fi integration is handled by ConnectivityManagerImpl_WiFi, which manages Wi-Fi provisioning, mode switching, and network status reporting.

This component does not use the esp_matter::start() function from esp_matter_core. Instead, it performs manual initialization of the Matter stack, including OTA setup, CHIP memory initialization, provider configuration, event loop startup, and event handler registration.

Unlike esp_matter::start(), it does not launch the Matter server, enable endpoints, initialize the data model, or run server-specific callbacks.

Matter Controller Initialization

The component initializes the Matter controller client with a given node ID, fabric ID, and port.

It locks the CHIP stack, sets up the controller, and optionally configures commissioner support if enabled.

Node ID—64‑bit unsigned, valid range from 0x0000000000000001 to 0xFFFFFFFFFFFFEFFF; 0x0000 and 0xFFFF_FFF0… are reserved.

Fabric ID—64‑bit unsigned non‑zero; 0 is reserved.

Listen Port—16‑bit integer; IANA‑assigned port for Matter over UDP and TCP.

Default values are:

  • MATTER_CONTROLLER_NODE_ID_DEFAULT 0x0000000000011234

  • MATTER_CONTROLLER_FABRIC_ID_DEFAULT 0x0000000000000001

  • MATTER_CONTROLLER_LISTEN_PORT_DEFAULT 5540

Utility Functions

This component provides helper functions to interact with Matter devices using the controller client. It wraps common commands like pairing, reading attributes, invoking cluster commands, and subscribing to attribute changes.

All functions internally manage CHIP stack locking and memory allocation for attribute/event paths.

References

Last modified: 30 April 2025