libertas_matter/lib.rs
1/*
2 *
3 * Copyright (c) 2020-2022 Project CHIP Authors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#![no_std]
19
20//! Native Rust Implementation of Matter (Smart-Home)
21//!
22//! This crate implements the Matter specification that can be run on embedded devices
23//! to build Matter-compatible smart-home/IoT devices.
24//!
25//! Currently Ethernet based transport is supported.
26//!
27//! # Examples
28//! ```ignore
29//! /// TODO: Fix once new API has stabilized a bit
30//! use rs_matter::{Matter, CommissioningData};
31//! use rs_matter::dm::device_types::device_type_add_on_off_light;
32//! use rs_matter::dm::cluster_basic_information::BasicInfoConfig;
33//! use rs_matter::sc::spake2p::VerifierData;
34//!
35//! # use rs_matter::dm::sdm::dev_att::{DataType, DevAttDataFetcher};
36//! # use rs_matter::error::Error;
37//! # pub struct DevAtt{}
38//! # impl DevAttDataFetcher for DevAtt{
39//! # fn get_devatt_data(&self, data_type: DataType, data: &mut [u8]) -> Result<usize, Error> { Ok(0) }
40//! # }
41//! # let dev_att = Box::new(DevAtt{});
42//!
43//! /// The commissioning data for this device
44//! let comm_data = CommissioningData {
45//! verifier: VerifierData::new_with_pw(123456),
46//! discriminator: 250,
47//! };
48//!
49//! /// The basic information about this device
50//! let dev_info = BasicInfoConfig {
51//! vid: 0x8000,
52//! pid: 0xFFF1,
53//! hw_ver: 2,
54//! sw_ver: 1,
55//! sw_ver_str: "1".to_string(),
56//! serial_no: "aabbcc".to_string(),
57//! device_name: "OnOff Light".to_string(),
58//! };
59//!
60//! /// Get the Matter Object
61//! /// The dev_att is an object that implements the DevAttDataFetcher trait.
62//! let mut matter = Matter::new(dev_info, dev_att, comm_data).unwrap();
63//! let dm = matter.get_data_model();
64//! {
65//! let mut node = dm.node.write().unwrap();
66//! /// Add our device-types
67//! let endpoint = device_type_add_on_off_light(&mut node).unwrap();
68//! }
69//! // Start the Matter Daemon
70//! // matter.start_daemon().unwrap();
71//! ```
72//!
73//! Start off exploring by going to the [Matter] object.
74
75/// Re-export the `libertas_matter_macros::import` proc-macro
76pub use libertas_matter_macros::import;
77
78#[cfg(feature = "alloc")]
79extern crate alloc;
80
81// This mod MUST go first, so that the others see its macros.
82pub(crate) mod fmt;
83
84pub mod error;
85pub mod im;
86pub mod tlv;
87pub mod utils;
88