Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Easily configure and run rs-matter
Overview
Configuring the rs-matter crate is not trivial, as it is more of a toolkit rather than a monolitic all-in-one runtime.
Furthermore, operating the assembled Matter stack is also challenging, as various features might need to be switched on or off depending on whether Matter is running in commissioning or operating mode, and also depending on the current network connectivity (as in e.g. Wifi signal lost).
This crate addresses these issues by providing an all-in-one MatterStack assembly that configures rs-matter for reliable operation.
Instantiate it and then call MatterStack::<...>::run(...).
OK, but what would I sacrifice?
Flexibility.
The Matter stack is assembled as one large future which is not Send. Using an executor to poll that future together with others is still possible, but the executor should be a local one (i.e. Embassy's embassy-executor, Tokio's LocalSet, async_executor::LocalExecutor and so on).
The examples are STD-only?
The core of rs-matter-stack is no_std and no-alloc.
You need to provide platform-specific implementations of the following traits for your embedded platform:
KvBlobStore- non-volatile key-value storage abstraction.- For STD,
rs-matter-stackprovidesDirKvBlobStore.
- For STD,
NetifDiag- network interface abstraction (i.e. monitoring when the network interface is up or down, and what is its IP configuration).- For Unix-like OSes,
rs-matterprovidesUnixNetifs, which uses a simple polling every 2 seconds to detect changes to the network interface. - Note that For IP (TCP & UDP) IO, the stack uses the
edge-nalcrate, and is thus compatible withSTDandEmbassyout of the box. You only need to worry about networking IO if you use other platforms than these two.
- For Unix-like OSes,
- Implementation of the UDP traits from edge-nal.
- There are out-of-the-box implementations for Rust STD BSD sockets as well as for
embassy-netand for OpenThread.
- There are out-of-the-box implementations for Rust STD BSD sockets as well as for
GattPeripheral- BLE GATT peripheral abstraction of the device radio. Not necessary for Ethernet connectivity- For Linux,
rs-matterprovidesBluerGattPeripheral, which uses the Linux BlueZ BT stack.
- For Linux,
NetCtl- Wifi controller implementation when using Wifi connectivity (Thread has a built-in one in OpenThread).NoopWirelessNetCtlis a no-op wireless implementation of a Wifi controller that is useful for testing. I.e. on Linux, one can usePreexistingWireless+NoopWirelessNetCtltogether withBluerGattPeripheralandUnixNetifsto test the stack in wireless mode. For production embedded Linux use-cases, you'll have to provide a trueNetCtlimplementation, possibly based on WPA Supplicant, or NetworkManager (which are in the meantime both available from upstreamrs-matter).
Endpoint 0
The root endpoint (Endpoint 0) hosts the Matter system clusters. Their ownership is split between you and the stack:
- You provide the clusters that do not depend on the operational network: Descriptor, Basic Information, Administrator Commissioning, Operational Credentials, Access Control, Group Key Management, Software Diagnostics and Time Synchronization.
MatterStack::root_handler(...)returns a handler chain with all of them, which you chain into your handler under an Endpoint 0 matcher, next to your application clusters. Any extra Endpoint 0 cluster you need (Diagnostic Logs, ICD Management, OTA Requestor, ...) is chained the same way. - The stack chains the operational network clusters on top of your handler: Network Commissioning, General Commissioning, General Diagnostics and the Ethernet / Wifi / Thread Network Diagnostics cluster. Only the stack knows their inputs - the network controller, the network interface and the commissioning mode - and with non-concurrent commissioning these change when the device hands the radio over from BLE to Wifi / Thread.
The metadata of the root endpoint is not split: MatterStack::root_endpoint() lists all clusters, and goes into your Node as-is.
Embassy
The rs-matter-embassy crate provides implementations for KvBlobStore, NetifDiag, NetCtl, GattPeripheral and others for the embassy framework.
ESP-IDF
The esp-idf-matter crate provides implementations for KvBlobStore, NetifDiag, GattPeripheral and others for the ESP-IDF SDK.
Example
(See also All examples)
//! An example utilizing the `EthMatterStack` struct.
//! As the name suggests, this Matter stack assembly uses Ethernet as the main transport,
//! as well as for commissioning.
//!
//! Notice that it might be that rather than Ethernet, the actual L2 transport is Wifi.
//! From the POV of Matter - this case is indistinguishable from Ethernet as long as the
//! Matter stack is not concerned with connecting to the Wifi network, managing
//! its credentials etc. and can assume it "pre-exists".
//!
//! The example implements a fictitious Light device (an On-Off Matter cluster).
use pin;
use info;
use EthMatterStack;
use ;
use on_off;
use TestOnOffDeviceLogic;
use OnOffHooks;
use desc;
use ClusterHandler as _;
use DAC_PRIVKEY;
use ;
use DEV_TYPE_ON_OFF_LIGHT;
use ROOT_ENDPOINT_ID;
use UnixNetifs;
use EmptyHandler;
use ;
use Error;
use DirKvBlobStore;
use ZeroconfMdns;
use InitMaybeUninit;
use ;
use StaticCell;
/// The amount of memory for allocating all `rs-matter-stack` futures created during
/// the execution of the `run*` methods.
/// This does NOT include the rest of the Matter stack.
///
/// The futures of `rs-matter-stack` created during the execution of the `run*` methods
/// are allocated in a special way using a small bump allocator which results
/// in a much lower memory usage by those.
///
/// If - for your platform - this size is not enough, increase it until
/// the program runs without panics during the stack initialization.
const BUMP_SIZE: usize = 23500;
/// The Matter stack is allocated statically to avoid
/// program stack blowups.
static MATTER_STACK: = new;
/// Endpoint 0 (the root endpoint) runs the Matter system clusters,
/// so we pick ID=1 for our light
const LIGHT_ENDPOINT_ID: u16 = 1;
/// The Matter Light device Node
const NODE: Node = Node ;
All examples
To build all examples, use:
cargo build --examples --features examples