├── scripts └── memory │ ├── memdf │ ├── util │ │ ├── __init__.py │ │ ├── pretty.py │ │ ├── subprocess.py │ │ ├── markdown.py │ │ └── nd.py │ ├── collector │ │ ├── __init__.py │ │ ├── util.py │ │ ├── csv.py │ │ ├── bloaty.py │ │ └── su.py │ ├── __init__.py │ ├── name.py │ └── README.md │ ├── README.md │ └── report_summary.py ├── .cargo └── config.toml ├── rs-matter ├── README.md ├── tests │ ├── macro_bench.rs │ ├── macro_bench │ │ └── basic_timings.rs │ ├── data_model_tests.rs │ ├── data_model │ │ └── mod.rs │ └── common │ │ └── mod.rs └── src │ ├── utils │ ├── rand.rs │ ├── codec.rs │ ├── sync.rs │ ├── zbus_proxies.rs │ ├── storage.rs │ ├── bitflags.rs │ ├── zbus_proxies │ │ ├── nm │ │ │ ├── device │ │ │ │ ├── ppp.rs │ │ │ │ ├── loopback.rs │ │ │ │ ├── ovs_interface.rs │ │ │ │ ├── vrf.rs │ │ │ │ ├── adsl.rs │ │ │ │ ├── wpan.rs │ │ │ │ ├── dummy.rs │ │ │ │ ├── veth.rs │ │ │ │ ├── ovs_port.rs │ │ │ │ ├── ovs_bridge.rs │ │ │ │ ├── infiniband.rs │ │ │ │ ├── generic.rs │ │ │ │ ├── lowpan.rs │ │ │ │ ├── wireguard.rs │ │ │ │ ├── bluetooth.rs │ │ │ │ ├── bond.rs │ │ │ │ ├── bridge.rs │ │ │ │ ├── olpc_mesh.rs │ │ │ │ ├── statistics.rs │ │ │ │ ├── ipvlan.rs │ │ │ │ ├── macvlan.rs │ │ │ │ ├── vlan.rs │ │ │ │ ├── team.rs │ │ │ │ ├── modem.rs │ │ │ │ ├── hsr.rs │ │ │ │ ├── wired.rs │ │ │ │ ├── tun.rs │ │ │ │ ├── wifi_p2p.rs │ │ │ │ ├── macsec.rs │ │ │ │ └── ip_tunnel.rs │ │ │ ├── dhcp4config.rs │ │ │ ├── dhcp6config.rs │ │ │ ├── vpn_connection.rs │ │ │ ├── checkpoint.rs │ │ │ ├── agent_manager.rs │ │ │ ├── dns_manager.rs │ │ │ ├── ppp.rs │ │ │ ├── wifi_p2ppeer.rs │ │ │ ├── access_point.rs │ │ │ ├── ip6config.rs │ │ │ └── ip4config.rs │ │ ├── bluez │ │ │ ├── gatt_profile.rs │ │ │ ├── sim_access.rs │ │ │ ├── le_advertisement.rs │ │ │ ├── battery.rs │ │ │ ├── admin_policy_set.rs │ │ │ ├── network_server.rs │ │ │ ├── thermometer_watcher.rs │ │ │ ├── media_control.rs │ │ │ ├── battery_provider_manager.rs │ │ │ ├── gatt_manager.rs │ │ │ ├── agent_manager.rs │ │ │ ├── gatt_service.rs │ │ │ ├── health_manager.rs │ │ │ ├── network.rs │ │ │ ├── profile_manager.rs │ │ │ ├── thermometer_manager.rs │ │ │ ├── health_device.rs │ │ │ ├── gatt_descriptor.rs │ │ │ ├── agent.rs │ │ │ ├── le_advertising_manager.rs │ │ │ ├── media.rs │ │ │ └── gatt_characteristic.rs │ │ ├── resolve.rs │ │ ├── wpa_supp.rs │ │ ├── avahi.rs │ │ ├── wpa_supp │ │ │ ├── persistent_group.rs │ │ │ ├── network.rs │ │ │ ├── wps.rs │ │ │ └── bss.rs │ │ ├── avahi │ │ │ ├── address_resolver.rs │ │ │ ├── host_name_resolver.rs │ │ │ ├── service_resolver.rs │ │ │ ├── domain_browser.rs │ │ │ ├── service_type_browser.rs │ │ │ ├── service_browser.rs │ │ │ └── record_browser.rs │ │ └── bluez.rs │ ├── zbus.rs │ ├── epoch.rs │ ├── sync │ │ └── notification.rs │ ├── iter.rs │ └── ipv6.rs │ ├── transport │ └── network │ │ ├── wifi.rs │ │ └── udp.rs │ ├── utils.rs │ ├── dm │ ├── networks.rs │ ├── types.rs │ ├── types │ │ ├── dataver.rs │ │ └── endpoint.rs │ ├── clusters │ │ ├── dev_att.rs │ │ └── eth_diag.rs │ ├── clusters.rs │ └── devices.rs │ ├── sc │ ├── crypto.rs │ └── crypto │ │ └── dummy.rs │ ├── im │ ├── timed.rs │ └── status.rs │ ├── group_keys.rs │ └── pairing.rs ├── .gitignore ├── devenv.yaml ├── .github ├── actions │ ├── git-safe-directory │ │ └── action.yaml │ ├── setup-size-reports │ │ └── action.yaml │ └── upload-size-reports │ │ └── action.yaml └── workflows │ ├── publish-macros-dry-run.yml │ ├── publish-macros.yml │ ├── publish-dry-run.yml │ ├── publish.yml │ ├── bloat-check.yaml │ └── size-check.yml ├── Cargo.toml ├── xtask ├── Cargo.toml └── README.md ├── banner.txt ├── rs-matter-macros ├── README.md ├── Cargo.toml └── src │ └── idl │ └── parser │ └── endpoint_composition.rs ├── examples ├── README.md ├── Cargo.toml └── src │ └── bin │ └── dimmable_light.pics ├── devenv.nix └── shell.nix /scripts/memory/memdf/util/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scripts/memory/memdf/collector/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | xtask = "run --quiet --manifest-path xtask/Cargo.toml --" -------------------------------------------------------------------------------- /scripts/memory/README.md: -------------------------------------------------------------------------------- 1 | Scripts copied from https://github.com/project-chip/connectedhomeip/tree/master/scripts/tools/memory -------------------------------------------------------------------------------- /rs-matter/README.md: -------------------------------------------------------------------------------- 1 | # rs-matter: The Rust Implementation of Matter Library 2 | 3 | This is the actual `rs-matter` library crate. See [the main README file](../README.md) for more information. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | Cargo.lock 3 | .vscode 4 | .idea 5 | 6 | # Nix 7 | .devenv/ 8 | .devenv.flake.nix 9 | devenv.lock 10 | 11 | # Build artifacts and temporary files from Xtask 12 | .build/ 13 | -------------------------------------------------------------------------------- /devenv.yaml: -------------------------------------------------------------------------------- 1 | inputs: 2 | nixpkgs: 3 | url: github:cachix/devenv-nixpkgs/rolling 4 | rust-overlay: 5 | url: github:oxalica/rust-overlay 6 | inputs: 7 | nixpkgs: 8 | follows: nixpkgs 9 | backend: nix 10 | -------------------------------------------------------------------------------- /rs-matter/tests/macro_bench.rs: -------------------------------------------------------------------------------- 1 | //! This module contains tests for the `rs-matter-macros` crate, specifically focusing on macro benchmarks. 2 | 3 | #[test] 4 | fn test_timings() { 5 | let t = trybuild::TestCases::new(); 6 | t.pass("tests/macro_bench/*.rs"); 7 | } 8 | -------------------------------------------------------------------------------- /.github/actions/git-safe-directory/action.yaml: -------------------------------------------------------------------------------- 1 | name: Git safe directory 2 | description: For running act with checkout owned by non-root user, e.g. docker 3 | runs: 4 | using: "composite" 5 | steps: 6 | - name: Set git safe.directory to "*" 7 | shell: bash 8 | run: git config --system --add safe.directory '*' -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ 4 | "rs-matter", 5 | "rs-matter-macros", 6 | "examples", 7 | ] 8 | 9 | exclude = ["tools/tlv", "xtask"] 10 | 11 | [profile.release] 12 | opt-level = "z" 13 | 14 | [profile.dev] 15 | debug = true 16 | opt-level = "z" 17 | 18 | [profile.flamegraph] 19 | inherits = "release" 20 | debug = true 21 | -------------------------------------------------------------------------------- /xtask/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "xtask" 3 | version = "0.1.0" 4 | edition = "2021" 5 | license = "MIT OR Apache-2.0" 6 | 7 | [dependencies] 8 | rs-matter = { path = "../rs-matter", default-features = false, features = ["rustcrypto", "std"] } 9 | anyhow = "1.0" 10 | log = "0.4" 11 | env_logger = "0.11" 12 | clap = { version = "4.0", features = ["derive"] } 13 | which = "4.4" 14 | tempfile = "3.8" 15 | -------------------------------------------------------------------------------- /xtask/README.md: -------------------------------------------------------------------------------- 1 | # xtask 2 | 3 | This directory contains the Rust-based task runner for `rs-matter` development tasks, particularly for running Chip YAML integration tests. 4 | 5 | ## Usage 6 | 7 | From the rs-matter root directory: 8 | 9 | ```bash 10 | cargo xtask --help 11 | ``` 12 | 13 | To get necessary environment configs (such as `gn`), you may also need to run: 14 | ```base 15 | source .build/itest/connectedhomeip/scripts/bootstrap.sh 16 | ``` -------------------------------------------------------------------------------- /banner.txt: -------------------------------------------------------------------------------- 1 | █ 2 | █ 3 | ▄ █ ▄ █ █ 4 | ▀▀█████▀▀ ▄▀▀ ▄▀▀▀▄ ▄▀▀▀▄ ▄▀▀▀▄ ▄▀▀▀▀▄█ ▀▀█▀▀▀▀▀█▀▀ ▄▀▀▀▀▄ ▄▀▀ 5 | ▀█▄ ▄█▀ █ ▀▄▄ ▄▄▄▄ █ █ █ █ █ █ █ █▄▄▄▄▄▄█ █ 6 | ▀█▄ ▄█▀ █ ▀▄ █ █ █ █ █ █ █ █ █ 7 | ▄██▀▀█ █▀▀██▄ █ ▀▄▄▄▀ █ █ █ ▀▄▄▄▄▀█ ▀▄▄ ▀▄▄ ▀▄▄▄▄▀ █ 8 | ▀▀ █ █ ▀▀ 9 | -------------------------------------------------------------------------------- /rs-matter/src/utils/rand.rs: -------------------------------------------------------------------------------- 1 | pub type Rand = fn(&mut [u8]); 2 | 3 | pub fn dummy_rand(buf: &mut [u8]) { 4 | // rust-crypto's KeyPair::new(rand) blocks on a zeroed buffer 5 | // Trick it a bit, as we use `dummy_rand` in our no_std tests 6 | for (i, b) in buf.iter_mut().enumerate() { 7 | *b = (i % 256) as u8; 8 | } 9 | } 10 | 11 | #[cfg(feature = "std")] 12 | pub fn sys_rand(buf: &mut [u8]) { 13 | use rand::{thread_rng, RngCore}; 14 | 15 | thread_rng().fill_bytes(buf); 16 | } 17 | -------------------------------------------------------------------------------- /rs-matter-macros/README.md: -------------------------------------------------------------------------------- 1 | # rs-matter-macros 2 | 3 | ### Proc-macros for the Rust implementation of Matter. 4 | 5 | * Proc-macros for deriving the `FromTLV` and `ToTLV` traits; 6 | * An `import!` proc-macro for generating Matter clusters' meta-data and handler traits. 7 | 8 | NOTE: The macros are re-exported by the `rs-matter` crate which should be used instead of adding a direct dependency on the `rs-matter-macros` crate. 9 | 10 | See [the main README file](../README.md) for more information about `rs-matter`. 11 | -------------------------------------------------------------------------------- /.github/actions/setup-size-reports/action.yaml: -------------------------------------------------------------------------------- 1 | name: Setup size reports 2 | description: Setup size reports 3 | inputs: 4 | gh-context: 5 | description: "GH Context" 6 | required: true 7 | 8 | runs: 9 | using: "composite" 10 | steps: 11 | - run: pip install numpy pandas humanfriendly pyelftools cxxfilt tabulate fastcore ghapi 12 | shell: bash 13 | - name: Set up environment for size reports 14 | shell: bash 15 | env: 16 | GH_CONTEXT: ${{ inputs.gh-context }} 17 | run: python scripts/memory/gh_sizes_environment.py "${GH_CONTEXT}" 18 | -------------------------------------------------------------------------------- /.github/actions/upload-size-reports/action.yaml: -------------------------------------------------------------------------------- 1 | name: upload-size-reports 2 | description: upload-size-reports 3 | inputs: 4 | platform-name: 5 | description: "Platform name Name" 6 | required: true 7 | 8 | runs: 9 | using: "composite" 10 | steps: 11 | - name: Uploading Size Reports 12 | uses: actions/upload-artifact@v4 13 | if: ${{ !env.ACT }} 14 | with: 15 | name: Size,${{ inputs.platform-name }}-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }} 16 | path: | 17 | /tmp/bloat_reports/ 18 | -------------------------------------------------------------------------------- /.github/workflows/publish-macros-dry-run.yml: -------------------------------------------------------------------------------- 1 | name: PublishMacrosDryRun 2 | 3 | on: workflow_dispatch 4 | 5 | env: 6 | RUST_TOOLCHAIN: stable 7 | 8 | jobs: 9 | publish_macros_dry_run: 10 | name: PublishMacrosDryRun 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Rust 14 | uses: dtolnay/rust-toolchain@v1 15 | with: 16 | toolchain: ${{ env.RUST_TOOLCHAIN }} 17 | components: rustfmt, clippy, rust-src 18 | 19 | - name: Checkout 20 | uses: actions/checkout@v3 21 | 22 | - name: PublishDryRun-Macros 23 | run: cargo publish -p rs-matter-macros --dry-run 24 | -------------------------------------------------------------------------------- /.github/workflows/publish-macros.yml: -------------------------------------------------------------------------------- 1 | name: PublishMacros 2 | 3 | on: workflow_dispatch 4 | 5 | env: 6 | RUST_TOOLCHAIN: stable 7 | 8 | jobs: 9 | publish_macros: 10 | name: PublishMacros 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Rust 14 | uses: dtolnay/rust-toolchain@v1 15 | with: 16 | toolchain: ${{ env.RUST_TOOLCHAIN }} 17 | components: rustfmt, clippy, rust-src 18 | 19 | - name: Checkout 20 | uses: actions/checkout@v3 21 | 22 | - name: Login 23 | run: cargo login ${{ secrets.CRATES_IO_TOKEN }} 24 | 25 | - name: Publish-Macros 26 | run: cargo publish -p rs-matter-macros 27 | -------------------------------------------------------------------------------- /rs-matter/tests/macro_bench/basic_timings.rs: -------------------------------------------------------------------------------- 1 | //! This test is used to benchmark the time it takes to parse and codegen the `import!` macro. 2 | 3 | rs_matter::import!( 4 | AdministratorCommissioning, 5 | AccessControl, 6 | BasicInformation, 7 | Descriptor, 8 | EthernetNetworkDiagnostics, 9 | GeneralDiagnostics, 10 | GeneralCommissioning, 11 | GroupKeyManagement, 12 | NetworkCommissioning, 13 | OnOff, 14 | OperationalCredentials, 15 | ThreadNetworkDiagnostics, 16 | WiFiNetworkDiagnostics; 17 | print_timings, 18 | cap_parse = 180, 19 | cap_codegen = 400 20 | ); 21 | 22 | // `trybench` wants this 23 | fn main() { 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/publish-dry-run.yml: -------------------------------------------------------------------------------- 1 | name: PublishDryRun 2 | 3 | on: workflow_dispatch 4 | 5 | env: 6 | RUST_TOOLCHAIN: stable 7 | CRATE_NAME: rs-matter 8 | 9 | jobs: 10 | publish_dry_run: 11 | name: PublishDryRun 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Rust 15 | uses: dtolnay/rust-toolchain@v1 16 | with: 17 | toolchain: ${{ env.RUST_TOOLCHAIN }} 18 | components: rustfmt, clippy, rust-src 19 | 20 | - name: Install libdbus 21 | run: sudo apt-get install -y libdbus-1-dev 22 | 23 | - name: Checkout 24 | uses: actions/checkout@v3 25 | 26 | - name: PublishDryRun 27 | run: cargo publish -p rs-matter --dry-run 28 | -------------------------------------------------------------------------------- /rs-matter/src/utils/codec.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 | pub mod base38; 19 | -------------------------------------------------------------------------------- /rs-matter/tests/data_model_tests.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 | mod common; 19 | mod data_model; 20 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # rs-matter-examples 2 | 3 | ### Examples for `rs-matter` 4 | 5 | Each example is a separate, standalone binary implementing a specific Matter device. 6 | Look at the code of each example for details. 7 | 8 | See [the main README file](../README.md) for more information about `rs-matter`. 9 | 10 | ### `dimmable-light` 11 | 12 | This is an example Matter device that implements the On/Off and LevelControl clusters and their interaction. 13 | 14 | #### Build 15 | 16 | `cargo build --bin dimmable_light --features avahi` 17 | 18 | #### test 19 | 20 | When building the application for testing against Matter yaml tests, use the feature `chip-test`. 21 | 22 | `cargo xtask itest --target dimmable_light --features chip-test Test_TC_LVL_1_1 Test_TC_LVL_2_1 Test_TC_LVL_2_2 Test_TC_LVL_3_1 Test_TC_LVL_4_1 Test_TC_LVL_5_1 Test_TC_LVL_6_1` -------------------------------------------------------------------------------- /rs-matter/src/transport/network/wifi.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 | pub mod band; 19 | #[cfg(feature = "zbus")] 20 | pub mod nm; 21 | #[cfg(feature = "zbus")] 22 | pub mod wpa_supp; 23 | -------------------------------------------------------------------------------- /rs-matter/tests/data_model/mod.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 | mod acl_and_dataver; 19 | mod attribute_lists; 20 | mod attributes; 21 | mod commands; 22 | mod long_reads; 23 | mod timed_requests; 24 | -------------------------------------------------------------------------------- /rs-matter/src/utils/sync.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 | pub use mutex::*; 19 | pub use notification::*; 20 | pub use signal::*; 21 | 22 | pub mod blocking; 23 | 24 | mod mutex; 25 | mod notification; 26 | mod signal; 27 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies.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 | //! A set of zbus proxies for various Linux services. 19 | 20 | pub mod avahi; 21 | pub mod bluez; 22 | pub mod nm; 23 | pub mod resolve; 24 | pub mod wpa_supp; 25 | -------------------------------------------------------------------------------- /rs-matter/src/utils/storage.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 | pub use parsebuf::*; 19 | pub use ringbuf::*; 20 | pub use vec::*; 21 | pub use writebuf::*; 22 | 23 | pub mod pooled; 24 | 25 | mod parsebuf; 26 | mod ringbuf; 27 | mod vec; 28 | mod writebuf; 29 | -------------------------------------------------------------------------------- /devenv.nix: -------------------------------------------------------------------------------- 1 | { pkgs, lib, config, inputs, ... }: 2 | 3 | { 4 | cachix.enable = false; 5 | 6 | packages = with pkgs; [ 7 | git 8 | cargo-expand 9 | pkg-config 10 | dbus 11 | avahi.dev 12 | libclang 13 | glibc.dev 14 | ]; 15 | 16 | env = { 17 | LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; 18 | BINDGEN_EXTRA_CLANG_ARGS = [ 19 | "-resource-dir=${pkgs.libclang.lib}/lib/clang/${lib.versions.major pkgs.libclang.version}" 20 | "-isystem ${pkgs.libclang.lib}/lib/clang/${lib.versions.major pkgs.libclang.version}/include" 21 | "-isystem ${pkgs.glibc.dev}/include" 22 | "-I ${pkgs.avahi.dev}/include" 23 | ]; 24 | }; 25 | 26 | languages.rust = { 27 | enable = true; 28 | channel = "nightly"; 29 | components = [ "cargo" "rustc" "rust-src" "rustfmt" "clippy"]; 30 | }; 31 | 32 | scripts.banner.exec = '' 33 | cat banner.txt 34 | ''; 35 | 36 | enterShell = '' 37 | banner 38 | ''; 39 | } 40 | -------------------------------------------------------------------------------- /rs-matter/src/utils/bitflags.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 | //! A module that re-exports the standard `bitflags!` macro if `defmt` is not enabled, or `defmt::bitflags!` if `defmt` is enabled. 19 | 20 | #[cfg(not(feature = "defmt"))] 21 | pub use bitflags::bitflags; 22 | 23 | #[cfg(feature = "defmt")] 24 | pub use defmt::bitflags; 25 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/ppp.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Ppp` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Ppp", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Ppp {} 27 | -------------------------------------------------------------------------------- /scripts/memory/memdf/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021 Project CHIP Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | """Package for working with memory usage information using Pandas DataFrame.""" 17 | 18 | from memdf.df import DF, DFs, ExtentDF, SectionDF, SegmentDF, SymbolDF 19 | from memdf.util.config import Config, ConfigDescription 20 | 21 | __all__ = [ 22 | 'DF', 'SymbolDF', 'SectionDF', 'SegmentDF', 'ExtentDF', 23 | 'DFs', 'Config', 'ConfigDescription', 24 | ] 25 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/gatt_profile.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 | //! # D-Bus interface proxy for: `org.bluez.GattProfile1` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy(interface = "org.bluez.GattProfile1", assume_defaults = true)] 23 | pub trait GattProfile { 24 | /// Release method 25 | fn release(&self) -> zbus::Result<()>; 26 | } 27 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/sim_access.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 | //! # D-Bus interface proxy for: `org.bluez.SimAccess1` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy(interface = "org.bluez.SimAccess1", assume_defaults = true)] 23 | pub trait SimAccess { 24 | /// Disconnect method 25 | fn disconnect(&self) -> zbus::Result<()>; 26 | } 27 | -------------------------------------------------------------------------------- /rs-matter/tests/common/mod.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 | pub mod e2e; 19 | 20 | pub fn init_env_logger() { 21 | #[cfg(all(feature = "std", not(target_os = "espidf")))] 22 | { 23 | let _ = env_logger::try_init_from_env( 24 | env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/le_advertisement.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 | //! # D-Bus interface proxy for: `org.bluez.LEAdvertisement1` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy(interface = "org.bluez.LEAdvertisement1", assume_defaults = true)] 23 | pub trait LEAdvertisement { 24 | /// Release method 25 | fn release(&self) -> zbus::Result<()>; 26 | } 27 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/loopback.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Loopback` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Loopback", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Loopback {} 27 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/battery.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 | //! # D-Bus interface proxy for: `org.bluez.Battery1` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy(interface = "org.bluez.Battery1", assume_defaults = true)] 23 | pub trait Battery { 24 | /// Percentage property 25 | #[zbus(property)] 26 | fn percentage(&self) -> zbus::Result; 27 | } 28 | -------------------------------------------------------------------------------- /rs-matter/src/utils.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 | pub mod bitflags; 19 | pub mod cell; 20 | pub mod codec; 21 | pub mod epoch; 22 | pub mod init; 23 | pub mod ipv6; 24 | pub mod iter; 25 | pub mod maybe; 26 | pub mod rand; 27 | pub mod select; 28 | pub mod storage; 29 | pub mod sync; 30 | #[cfg(feature = "zbus")] 31 | pub mod zbus; 32 | #[cfg(feature = "zbus")] 33 | pub mod zbus_proxies; 34 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/ovs_interface.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.OvsInterface` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.OvsInterface", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait OvsInterface {} 27 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/resolve.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 | //! zbus proxies for `org.freedesktop.resolve1`. 19 | //! 20 | //! All proxy traits are generated using introspection (i.e. `zbus-xmlgen system org.freedesktop.resolve1 /org/freedesktop/resolve1`). 21 | //! Also look here: https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.resolve1.html 22 | 23 | pub mod manager; 24 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/admin_policy_set.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 | //! # D-Bus interface proxy for: `org.bluez.AdminPolicySet1` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy(interface = "org.bluez.AdminPolicySet1", assume_defaults = true)] 23 | pub trait AdminPolicySet { 24 | /// SetServiceAllowList method 25 | fn set_service_allow_list(&self, uuids: &[&str]) -> zbus::Result<()>; 26 | } 27 | -------------------------------------------------------------------------------- /scripts/memory/memdf/util/pretty.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021 Project CHIP Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | """Pretty print logging.""" 17 | 18 | import logging 19 | import pprint 20 | from typing import Any 21 | 22 | 23 | def log(level: int, x: Any) -> None: 24 | if logging.getLogger(None).isEnabledFor(level): 25 | for line in pprint.pformat(x).split('\n'): 26 | logging.log(level, line) 27 | 28 | 29 | def info(x: Any) -> None: 30 | log(logging.INFO, x) 31 | 32 | 33 | def debug(x: Any) -> None: 34 | log(logging.DEBUG, x) 35 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/vrf.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Vrf` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Vrf", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Vrf { 27 | /// Table property 28 | #[zbus(property)] 29 | fn table(&self) -> zbus::Result; 30 | } 31 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/adsl.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Adsl` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Adsl", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Adsl { 27 | /// Carrier property 28 | #[zbus(property)] 29 | fn carrier(&self) -> zbus::Result; 30 | } 31 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/wpan.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Wpan` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Wpan", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Wpan { 27 | /// HwAddress property 28 | #[zbus(property)] 29 | fn hw_address(&self) -> zbus::Result; 30 | } 31 | -------------------------------------------------------------------------------- /scripts/memory/memdf/util/subprocess.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021 Project CHIP Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | """Subprocess utilities.""" 17 | 18 | import logging 19 | import subprocess 20 | from typing import List 21 | 22 | from memdf.util.config import Config 23 | 24 | 25 | def run_tool_pipe(config: Config, command: List[str]) -> subprocess.Popen: 26 | """Run a command.""" 27 | if tool := config.getl(['tool', command[0]]): 28 | command[0] = tool 29 | logging.info('Execute: %s', ' '.join(command)) 30 | return subprocess.Popen(command, stdout=subprocess.PIPE) 31 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/dummy.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Dummy` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Dummy", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Dummy { 27 | /// HwAddress property 28 | #[zbus(property)] 29 | fn hw_address(&self) -> zbus::Result; 30 | } 31 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/network_server.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 | //! # D-Bus interface proxy for: `org.bluez.NetworkServer1` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy(interface = "org.bluez.NetworkServer1", default_service = "org.bluez")] 23 | pub trait NetworkServer { 24 | /// Register method 25 | fn register(&self, uuid: &str, bridge: &str) -> zbus::Result<()>; 26 | 27 | /// Unregister method 28 | fn unregister(&self, uuid: &str) -> zbus::Result<()>; 29 | } 30 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/thermometer_watcher.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 | //! # D-Bus interface proxy for: `org.bluez.ThermometerWatcher1` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::{proxy, zvariant::Value}; 23 | 24 | #[proxy(interface = "org.bluez.ThermometerWatcher1", assume_defaults = true)] 25 | pub trait ThermometerWatcher { 26 | /// MeasurementReceived method 27 | fn measurement_received(&self, measurement: HashMap<&str, &Value<'_>>) -> zbus::Result<()>; 28 | } 29 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/veth.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Veth` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.Veth", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait Veth { 28 | /// Peer property 29 | #[zbus(property)] 30 | fn slaves(&self) -> zbus::Result; 31 | } 32 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/wpa_supp.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 | //! zbus proxies for wpa-supplicant. 19 | //! 20 | //! All proxy traits are manually implemented based on the wpa-supplicant D-Bus interface definitions 21 | //! as documented here: https://w1.fi/wpa_supplicant/devel/dbus.html circa 2025-07-15 22 | 23 | pub mod bss; 24 | pub mod group; 25 | pub mod interface; 26 | pub mod network; 27 | pub mod p2pdevice; 28 | pub mod peer; 29 | pub mod persistent_group; 30 | pub mod wpa_supplicant; 31 | pub mod wps; 32 | -------------------------------------------------------------------------------- /examples/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rs-matter-examples" 3 | version = "0.1.0" 4 | edition = "2021" 5 | license = "MIT OR Apache-2.0" 6 | 7 | [[bin]] 8 | name = "onoff_light" 9 | 10 | [[bin]] 11 | name = "onoff_light_bt" 12 | required-features = ["zbus"] 13 | 14 | [[bin]] 15 | name = "speaker" 16 | 17 | [[bin]] 18 | name = "media_player" 19 | 20 | [[bin]] 21 | name = "bridge" 22 | 23 | [[bin]] 24 | name = "chip_tool_tests" 25 | 26 | [[bin]] 27 | name = "dimmable_light" 28 | 29 | [features] 30 | default = ["log"] 31 | log = [] 32 | zbus = ["rs-matter/zbus"] 33 | astro-dnssd = ["rs-matter/astro-dnssd"] 34 | zeroconf = ["rs-matter/zeroconf"] 35 | avahi = ["rs-matter/zbus"] 36 | resolve = ["rs-matter/zbus"] 37 | chip-test = [] 38 | 39 | [dependencies] 40 | log = "0.4" 41 | env_logger = "0.11" 42 | embassy-futures = "0.1" 43 | embassy-sync = "0.7" 44 | embassy-time = { version = "0.5", features = ["std"] } 45 | embassy-time-queue-utils = { version = "0.3", features = ["generic-queue-64"] } 46 | static_cell = "1" 47 | nix = { version = "0.27", features = ["net"] } 48 | async-io = "2" 49 | futures-lite = "2" 50 | rs-matter = { path = "../rs-matter", features = ["async-io"] } 51 | async-signal = "0.2" 52 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/ovs_port.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.OvsPort` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.OvsPort", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait OvsPort { 28 | /// Slaves property 29 | #[zbus(property)] 30 | fn slaves(&self) -> zbus::Result>; 31 | } 32 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/media_control.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 | //! # D-Bus interface proxy for: `org.bluez.MediaControl1` 19 | 20 | use zbus::{proxy, zvariant::OwnedObjectPath}; 21 | 22 | #[proxy(interface = "org.bluez.MediaControl1", assume_defaults = true)] 23 | pub trait MediaControl { 24 | /// Connected property 25 | #[zbus(property)] 26 | fn connected(&self) -> zbus::Result; 27 | 28 | /// Player property 29 | #[zbus(property)] 30 | fn player(&self) -> zbus::Result; 31 | } 32 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/ovs_bridge.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.OvsBridge` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.OvsBridge", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait OvsBridge { 28 | /// Slaves property 29 | #[zbus(property)] 30 | fn slaves(&self) -> zbus::Result>; 31 | } 32 | -------------------------------------------------------------------------------- /rs-matter-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rs-matter-macros" 3 | version = "0.1.0" 4 | edition = "2021" 5 | authors = [ 6 | "Kedar Sovani ", 7 | "Ivan Markov", 8 | "Project CHIP Authors", 9 | ] 10 | description = "Native Rust implementation of the Matter (Smart-Home) ecosystem - Proc-macros" 11 | repository = "https://github.com/project-chip/matter-rs" 12 | readme = "README.md" 13 | keywords = ["matter", "smart", "smart-home", "IoT", "ESP32"] 14 | categories = ["embedded", "network-programming"] 15 | license = "Apache-2.0" 16 | 17 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 18 | [lib] 19 | proc-macro = true 20 | 21 | [dependencies] 22 | syn = { version = "2", features = ["extra-traits", "parsing"] } 23 | quote = "1" 24 | proc-macro2 = "1" 25 | proc-macro-crate = "3" 26 | miette = { version = "5", features = ["fancy"] } 27 | nom = "7" 28 | nom-greedyerror = "0.5" 29 | nom-supreme = "0.8" 30 | nom_locate = "4.2" 31 | convert_case = "0.6" 32 | thiserror = "1" 33 | tracing = "0.1" 34 | tracing-subscriber = { version = "0.3", features = ["regex", "json"] } 35 | 36 | [dev-dependencies] 37 | assert-tokenstreams-eq = "0.1.0" 38 | rstest = "0.18.2" 39 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/dhcp4config.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.DHCP4Config` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::proxy; 23 | use zbus::zvariant::OwnedValue; 24 | 25 | #[proxy( 26 | interface = "org.freedesktop.NetworkManager.DHCP4Config", 27 | default_service = "org.freedesktop.NetworkManager" 28 | )] 29 | pub trait DHCP4Config { 30 | /// Options property 31 | #[zbus(property)] 32 | fn options(&self) -> zbus::Result>; 33 | } 34 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/dhcp6config.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.DHCP6Config` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::proxy; 23 | use zbus::zvariant::OwnedValue; 24 | 25 | #[proxy( 26 | interface = "org.freedesktop.NetworkManager.DHCP6Config", 27 | default_service = "org.freedesktop.NetworkManager" 28 | )] 29 | pub trait DHCP6Config { 30 | /// Options property 31 | #[zbus(property)] 32 | fn options(&self) -> zbus::Result>; 33 | } 34 | -------------------------------------------------------------------------------- /scripts/memory/memdf/name.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021 Project CHIP Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | """Special section/symbol names.""" 18 | 19 | ABS = '*ABS*' 20 | UNDEF = '*UNDEF*' 21 | UNKNOWN = '*unknown*' 22 | OTHER = '*other*' 23 | TOTAL = '*total*' 24 | 25 | GAP_PREFIX = '*GAP_' 26 | UNUSED_PREFIX = '*UNUSED_' 27 | OVERLAP_PREFIX = '*OVERLAP_' 28 | 29 | 30 | def gap(address: int, size: int) -> str: 31 | return f'{GAP_PREFIX}{address:X}_{size:X}*' 32 | 33 | 34 | def unused(address: int, size: int) -> str: 35 | return f'{UNUSED_PREFIX}{address:X}_{size:X}*' 36 | 37 | 38 | def overlap(address: int, size: int) -> str: 39 | return f'{OVERLAP_PREFIX}{address:X}_{size:X}*' 40 | -------------------------------------------------------------------------------- /scripts/memory/memdf/collector/util.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021 Project CHIP Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | """Miscellaneous collection utilities""" 17 | 18 | import os 19 | import re 20 | from typing import Optional 21 | 22 | 23 | def simplify_source(source: str, prefixes: Optional[re.Pattern]) -> str: 24 | """Simplify a source file path.""" 25 | r = source 26 | if prefixes: 27 | if (m := prefixes.match(source)): 28 | r = r[m.end():] 29 | if r.startswith(os.path.sep): 30 | r = r[len(os.path.sep):] 31 | while r.startswith('..'): 32 | r = r[2:] 33 | if r.startswith(os.path.sep): 34 | r = r[len(os.path.sep):] 35 | return r 36 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/infiniband.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Infiniband` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Infiniband", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Infiniband { 27 | /// HwAddress property 28 | #[zbus(property)] 29 | fn hw_address(&self) -> zbus::Result; 30 | 31 | /// Carrier property 32 | #[zbus(property)] 33 | fn carrier(&self) -> zbus::Result; 34 | } 35 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/generic.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Generic` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Generic", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Dummy { 27 | /// HwAddress property 28 | #[zbus(property)] 29 | fn hw_address(&self) -> zbus::Result; 30 | 31 | /// TypeDescription property 32 | #[zbus(property)] 33 | fn type_description(&self) -> zbus::Result; 34 | } 35 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { 2 | overlays = [ 3 | (import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz")) 4 | ]; 5 | } 6 | }: 7 | 8 | (pkgs.buildFHSEnv { 9 | name = "rs-matter-test-env"; 10 | runScript = builtins.getEnv "SHELL"; 11 | 12 | targetPkgs = pkgs: with pkgs; [ 13 | # rust support 14 | rust-bin.stable.latest.default 15 | 16 | # Provide non-privileged execution of `ip` commands 17 | iproute2 18 | iptables 19 | 20 | # connectedhomeip requirements 21 | bash 22 | git 23 | gcc 24 | glib 25 | glib.dev 26 | pkg-config 27 | cmake 28 | ninja 29 | gn 30 | gobject-introspection.dev 31 | gobject-introspection.out 32 | openssl.dev 33 | dbus.dev 34 | avahi.dev 35 | unzip 36 | cairo.dev 37 | readline.dev 38 | jre 39 | libffi.dev 40 | zap-chip 41 | 42 | ## python support 43 | # Note: python 3.11 is required due to the deprecation of the `imp` module in newer versions of python. 44 | python311 45 | python311Packages.pip 46 | python311Packages.virtualenv 47 | ]; 48 | 49 | }).env 50 | -------------------------------------------------------------------------------- /examples/src/bin/dimmable_light.pics: -------------------------------------------------------------------------------- 1 | PICS_SDK_CI_ONLY=1 2 | # PICS values to be used when running the `dimmable_light` executable 3 | 4 | # Level Control Cluster 5 | LVL.S=1 6 | LVL.S.F00=1 7 | LVL.S.F01=1 8 | LVL.S.F02=0 9 | LVL.S.A0000=1 10 | LVL.S.A0001=1 11 | LVL.S.A0002=1 12 | LVL.S.A0003=1 13 | LVL.S.A0005=0 14 | LVL.S.A0004=0 15 | LVL.S.A0006=0 16 | LVL.S.A000f=1 17 | LVL.S.A0010=1 18 | LVL.S.A0011=1 19 | LVL.S.A0012=1 20 | LVL.S.A0013=1 21 | LVL.S.A0014=1 22 | LVL.S.A4000=1 23 | LVL.S.C00.Rsp=1 24 | LVL.S.C01.Rsp=1 25 | LVL.S.C02.Rsp=1 26 | LVL.S.C03.Rsp=1 27 | LVL.S.C04.Rsp=1 28 | LVL.S.C05.Rsp=1 29 | LVL.S.C06.Rsp=1 30 | LVL.S.C07.Rsp=1 31 | LVL.S.C08.Rsp=0 32 | LVL.S.M.VarRate=1 33 | 34 | LVL.C=0 35 | LVL.C.AM-READ=0 36 | LVL.C.AM-WRITE=0 37 | LVL.C.AO-READ=0 38 | LVL.C.AO-WRITE=0 39 | 40 | # On/Off Cluster 41 | OO.S=1 42 | OO.S.A0000=1 43 | OO.S.A4000=1 44 | OO.S.A4001=1 45 | OO.S.A4002=1 46 | OO.S.A4003=1 47 | OO.S.C00.Rsp=1 48 | OO.S.C01.Rsp=1 49 | OO.S.C02.Rsp=1 50 | OO.S.C40.Rsp=1 51 | OO.S.C41.Rsp=0 52 | OO.S.C42.Rsp=1 53 | OO.S.F00=1 54 | OO.S.F01=0 55 | OO.S.F02=0 56 | OO.M.ManuallyControlled=1 57 | 58 | OO.C=0 59 | OO.C.C00.Tx=0 60 | OO.C.C01.Tx=0 61 | OO.C.C02.Tx=0 62 | OO.C.C40.Tx=0 63 | OO.C.C41.Tx=0 64 | OO.C.C42.Tx=0 65 | OO.C.AM-READ=0 66 | OO.C.AM-WRITE=0 67 | OO.C.AO-READ=0 68 | OO.C.AO-WRITE=0 69 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: workflow_dispatch 4 | 5 | env: 6 | RUST_TOOLCHAIN: stable 7 | CRATE_NAME: rs-matter 8 | 9 | jobs: 10 | publish: 11 | name: Publish 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Rust 15 | uses: dtolnay/rust-toolchain@v1 16 | with: 17 | toolchain: ${{ env.RUST_TOOLCHAIN }} 18 | components: rustfmt, clippy, rust-src 19 | 20 | - name: Install libdbus 21 | run: sudo apt-get install -y libdbus-1-dev 22 | 23 | - name: Checkout 24 | uses: actions/checkout@v3 25 | 26 | - name: Login 27 | run: cargo login ${{ secrets.CRATES_IO_TOKEN }} 28 | 29 | - name: Publish 30 | run: cargo publish -p rs-matter 31 | 32 | - name: Get the crate version from cargo 33 | run: | 34 | version=$(cd rs-matter; cargo metadata --format-version=1 --no-deps | jq -r ".packages[] | select(.name == \"${{env.CRATE_NAME}}\") | .version") 35 | echo "crate_version=$version" >> $GITHUB_ENV 36 | echo "${{env.CRATE_NAME}} version: $version" 37 | 38 | - name: Tag the new release 39 | uses: rickstaa/action-create-tag@v1 40 | with: 41 | tag: v${{env.crate_version}} 42 | message: "Release v${{env.crate_version}}" 43 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/avahi.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 | //! zbus proxies for `org.freedesktop.resolve1`. 19 | //! 20 | //! All proxy traits are generated using introspection (i.e. `zbus-xmlgen file ...`), 21 | //! with introspection (.xml) files as available here (circa 2025-07-15): 22 | //! https://github.com/avahi/avahi/tree/master/avahi-daemon 23 | 24 | pub mod address_resolver; 25 | pub mod domain_browser; 26 | pub mod entry_group; 27 | pub mod host_name_resolver; 28 | pub mod record_browser; 29 | pub mod server; 30 | pub mod server2; 31 | pub mod service_browser; 32 | pub mod service_resolver; 33 | pub mod service_type_browser; 34 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/lowpan.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Lowpan` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.Lowpan", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait Lowpan { 28 | /// HwAddress property 29 | #[zbus(property)] 30 | fn hw_address(&self) -> zbus::Result; 31 | 32 | /// Parent property 33 | #[zbus(property)] 34 | fn parent(&self) -> zbus::Result; 35 | } 36 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/battery_provider_manager.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 | //! # D-Bus interface proxy for: `org.bluez.BatteryProviderManager1` 19 | 20 | use zbus::{proxy, zvariant::ObjectPath}; 21 | 22 | #[proxy( 23 | interface = "org.bluez.BatteryProviderManager1", 24 | default_service = "org.bluez" 25 | )] 26 | pub trait BatteryProviderManager { 27 | /// RegisterBatteryProvider method 28 | fn register_battery_provider(&self, provider: &ObjectPath<'_>) -> zbus::Result<()>; 29 | 30 | /// UnregisterBatteryProvider method 31 | fn unregister_battery_provider(&self, provider: &ObjectPath<'_>) -> zbus::Result<()>; 32 | } 33 | -------------------------------------------------------------------------------- /rs-matter/src/dm/networks.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 | //! A module containing various types for managing Ethernet, Thread and Wifi networks. 19 | 20 | use core::future::Future; 21 | 22 | pub mod eth; 23 | #[cfg(all(unix, feature = "os", not(target_os = "espidf")))] 24 | pub mod unix; 25 | pub mod wireless; 26 | 27 | /// A generic trait for network change notifications. 28 | pub trait NetChangeNotif { 29 | /// Wait until a change occurs. 30 | async fn wait_changed(&self); 31 | } 32 | 33 | impl NetChangeNotif for &T 34 | where 35 | T: NetChangeNotif, 36 | { 37 | fn wait_changed(&self) -> impl Future { 38 | (*self).wait_changed() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/wireguard.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.WireGuard` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.WireGuard", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait WireGuard { 27 | /// PublicKey property 28 | #[zbus(property)] 29 | fn public_key(&self) -> zbus::Result>; 30 | 31 | /// ListenPort property 32 | #[zbus(property)] 33 | fn listen_port(&self) -> zbus::Result; 34 | 35 | /// FwMark property 36 | #[zbus(property)] 37 | fn fw_mark(&self) -> zbus::Result; 38 | } 39 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/bluetooth.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Bridge` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Bluetooth", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Bluetooth { 27 | /// Name property 28 | #[zbus(property)] 29 | fn name(&self) -> zbus::Result; 30 | 31 | /// HwAddress property 32 | #[zbus(property)] 33 | fn hw_address(&self) -> zbus::Result; 34 | 35 | /// BtCapabilities property 36 | #[zbus(property)] 37 | fn bt_capabilities(&self) -> zbus::Result; 38 | } 39 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/gatt_manager.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 | //! # D-Bus interface proxy for: `org.bluez.GattManager1` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::{ 23 | proxy, 24 | zvariant::{ObjectPath, Value}, 25 | }; 26 | 27 | #[proxy(interface = "org.bluez.GattManager1", default_service = "org.bluez")] 28 | pub trait GattManager { 29 | /// RegisterApplication method 30 | fn register_application( 31 | &self, 32 | application: &ObjectPath<'_>, 33 | options: HashMap<&str, &Value<'_>>, 34 | ) -> zbus::Result<()>; 35 | 36 | /// UnregisterApplication method 37 | fn unregister_application(&self, application: &ObjectPath<'_>) -> zbus::Result<()>; 38 | } 39 | -------------------------------------------------------------------------------- /scripts/memory/memdf/collector/csv.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021 Project CHIP Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | """Collect memory information from csv files.""" 17 | 18 | import memdf.name 19 | import pandas as pd # type: ignore 20 | from memdf.df import DFs 21 | from memdf.util.config import Config, ConfigDescription 22 | 23 | CONFIG: ConfigDescription = {} 24 | 25 | 26 | def read_file(config: Config, filename: str, method: str = ',') -> DFs: 27 | """Read a csv or tsv file into a data frame.""" 28 | delimiter = {'csv': ',', 'tsv': '\t'}.get(method, method) 29 | df = pd.read_csv(open(filename, 'r'), sep=delimiter, na_filter=False) 30 | if df_class := memdf.df.find_class(df): 31 | df_name = df.name 32 | df = df.astype(df_class.dtype) 33 | else: 34 | df_name = memdf.name.UNKNOWN 35 | return {df_name: df} 36 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/vpn_connection.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.VPN.Connection` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.VPN.Connection", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait VPNConnection { 27 | /// VpnStateChanged signal 28 | #[zbus(signal)] 29 | fn vpn_state_changed_signal(&self, state: u32, reason: u32) -> zbus::Result; 30 | 31 | /// VpnState property 32 | #[zbus(property)] 33 | fn vpn_state(&self) -> zbus::Result; 34 | 35 | /// Banner property 36 | #[zbus(property)] 37 | fn banner(&self) -> zbus::Result; 38 | } 39 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/bond.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Bridge` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.Bond", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait Bond { 28 | /// Carrier property 29 | #[zbus(property)] 30 | fn carrier(&self) -> zbus::Result; 31 | 32 | /// HwAddress property 33 | #[zbus(property)] 34 | fn hw_address(&self) -> zbus::Result; 35 | 36 | /// Slaves property 37 | #[zbus(property)] 38 | fn slaves(&self) -> zbus::Result>; 39 | } 40 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/agent_manager.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 | //! # D-Bus interface proxy for: `org.bluez.AgentManager1` 19 | 20 | use zbus::{proxy, zvariant::ObjectPath}; 21 | 22 | #[proxy( 23 | interface = "org.bluez.AgentManager1", 24 | default_service = "org.bluez", 25 | default_path = "/org/bluez" 26 | )] 27 | pub trait AgentManager { 28 | /// RegisterAgent method 29 | fn register_agent(&self, agent: &ObjectPath<'_>, capability: &str) -> zbus::Result<()>; 30 | 31 | /// RequestDefaultAgent method 32 | fn request_default_agent(&self, agent: &ObjectPath<'_>) -> zbus::Result<()>; 33 | 34 | /// UnregisterAgent method 35 | fn unregister_agent(&self, agent: &ObjectPath<'_>) -> zbus::Result<()>; 36 | } 37 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/bridge.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Bridge` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.Bridge", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait Bridge { 28 | /// Carrier property 29 | #[zbus(property)] 30 | fn carrier(&self) -> zbus::Result; 31 | 32 | /// HwAddress property 33 | #[zbus(property)] 34 | fn hw_address(&self) -> zbus::Result; 35 | 36 | /// Slaves property 37 | #[zbus(property)] 38 | fn slaves(&self) -> zbus::Result>; 39 | } 40 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/checkpoint.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Checkpoint` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Checkpoint", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait Checkpoint { 28 | /// Devices property 29 | #[zbus(property)] 30 | fn devices(&self) -> zbus::Result>; 31 | 32 | /// Created property 33 | #[zbus(property)] 34 | fn created(&self) -> zbus::Result; 35 | 36 | /// RollbackTimeout property 37 | #[zbus(property)] 38 | fn rollback_timeout(&self) -> zbus::Result; 39 | } 40 | -------------------------------------------------------------------------------- /scripts/memory/memdf/util/markdown.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021 Project CHIP Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | """Markdown utilities.""" 17 | 18 | 19 | def read_hierified(f): 20 | """Read a markdown table in ‘hierified’ format.""" 21 | 22 | line = f.readline() 23 | header = tuple((s.strip() for s in line.split('|')[1:-1])) 24 | 25 | _ = f.readline() # The line under the header. 26 | 27 | rows = [] 28 | for line in f: 29 | line = line.strip() 30 | if not line: 31 | break 32 | row = [] 33 | columns = line.split('|') 34 | for i in range(0, len(header)): 35 | column = columns[i + 1].strip() 36 | if not column: 37 | column = rows[-1][i] if rows else '(blank)' 38 | row.append(column) 39 | rows.append(tuple(row)) 40 | 41 | return (header, rows) 42 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/wpa_supp/persistent_group.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 | //! # D-Bus interface proxy for: `fi.w1.wpa_supplicant1.Interface.PersistentGroup` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::proxy; 23 | use zbus::zvariant::{OwnedValue, Value}; 24 | 25 | #[proxy( 26 | interface = "fi.w1.wpa_supplicant1.PersistentGroup", 27 | default_service = "fi.w1.wpa_supplicant1" 28 | )] 29 | pub trait PersistentGroup { 30 | /// PropertiesChanged signal 31 | #[zbus(signal)] 32 | fn properties_changed(&self, properties: HashMap<&str, Value<'_>>) -> zbus::Result<()>; 33 | 34 | /// Properties property 35 | #[zbus(property, name = "Properties")] 36 | fn props(&self) -> zbus::Result>; 37 | } 38 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/agent_manager.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.AgentManager` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.AgentManager", 24 | default_service = "org.freedesktop.NetworkManager", 25 | default_path = "/org/freedesktop/NetworkManager/AgentManager" 26 | )] 27 | pub trait AgentManager { 28 | /// Register method 29 | fn register(&self, identifier: &str) -> zbus::Result<()>; 30 | 31 | /// RegisterWithCapabilities method 32 | fn register_with_capabilities(&self, identifier: &str, capabilities: u32) -> zbus::Result<()>; 33 | 34 | /// Unregister method 35 | fn unregister(&self) -> zbus::Result<()>; 36 | } 37 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/olpc_mesh.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.OlpcMesh` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.OlpcMesh", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait OlpcMesh { 28 | /// HwAddress property 29 | #[zbus(property)] 30 | fn hw_address(&self) -> zbus::Result; 31 | 32 | /// Companion property 33 | #[zbus(property)] 34 | fn companion(&self) -> zbus::Result; 35 | 36 | /// ActiveChannel property 37 | #[zbus(property)] 38 | fn active_channel(&self) -> zbus::Result; 39 | } 40 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/gatt_service.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 | //! # D-Bus interface proxy for: `org.bluez.GattService1` 19 | 20 | use zbus::{proxy, zvariant::OwnedObjectPath}; 21 | 22 | #[proxy(interface = "org.bluez.GattService1", assume_defaults = true)] 23 | pub trait GattService { 24 | /// Device property 25 | #[zbus(property)] 26 | fn device(&self) -> zbus::Result; 27 | 28 | /// Includes property 29 | #[zbus(property)] 30 | fn includes(&self) -> zbus::Result>; 31 | 32 | /// Primary property 33 | #[zbus(property)] 34 | fn primary(&self) -> zbus::Result; 35 | 36 | /// UUID property 37 | #[zbus(property, name = "UUID")] 38 | fn uuid(&self) -> zbus::Result; 39 | } 40 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/health_manager.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 | //! # D-Bus interface proxy for: `org.bluez.HealthManager1` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::{ 23 | proxy, 24 | zvariant::{ObjectPath, OwnedObjectPath, Value}, 25 | }; 26 | 27 | #[proxy( 28 | interface = "org.bluez.HealthManager1", 29 | default_service = "org.bluez", 30 | default_path = "/org/bluez" 31 | )] 32 | pub trait HealthManager { 33 | /// CreateApplication method 34 | fn create_application( 35 | &self, 36 | config: HashMap<&str, &Value<'_>>, 37 | ) -> zbus::Result; 38 | 39 | /// DestroyApplication method 40 | fn destroy_application(&self, application: &ObjectPath<'_>) -> zbus::Result<()>; 41 | } 42 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus.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 | //! A re-export of the `zbus` crate, which provides D-Bus support in Rust. 19 | 20 | pub use ::zbus::*; 21 | 22 | use crate::error::ErrorCode; 23 | 24 | impl From for crate::error::Error { 25 | fn from(e: zbus::Error) -> Self { 26 | Self::new_with_details(ErrorCode::DBusError, Box::new(e)) 27 | } 28 | } 29 | 30 | impl From for crate::error::Error { 31 | fn from(e: zbus::zvariant::Error) -> Self { 32 | Self::new_with_details(ErrorCode::DBusError, Box::new(e)) 33 | } 34 | } 35 | 36 | impl From for crate::error::Error { 37 | fn from(e: zbus::fdo::Error) -> Self { 38 | Self::new_with_details(ErrorCode::DBusError, Box::new(e)) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/network.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 | //! # D-Bus interface proxy for: `org.bluez.Network1` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy(interface = "org.bluez.Network1", assume_defaults = true)] 23 | pub trait Network { 24 | /// Connect method 25 | fn connect(&self, uuid: &str) -> zbus::Result; 26 | 27 | /// Disconnect method 28 | fn disconnect(&self) -> zbus::Result<()>; 29 | 30 | /// Connected property 31 | #[zbus(property)] 32 | fn connected(&self) -> zbus::Result; 33 | 34 | /// Interface property 35 | #[zbus(property)] 36 | fn interface(&self) -> zbus::Result; 37 | 38 | /// UUID property 39 | #[zbus(property, name = "UUID")] 40 | fn uuid(&self) -> zbus::Result; 41 | } 42 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/profile_manager.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 | //! # D-Bus interface proxy for: `org.bluez.ProfileManager1` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::{ 23 | proxy, 24 | zvariant::{ObjectPath, Value}, 25 | }; 26 | 27 | #[proxy( 28 | interface = "org.bluez.ProfileManager1", 29 | default_service = "org.bluez", 30 | default_path = "/org/bluez" 31 | )] 32 | pub trait ProfileManager { 33 | /// RegisterProfile method 34 | fn register_profile( 35 | &self, 36 | profile: &ObjectPath<'_>, 37 | uuid: &str, 38 | options: HashMap<&str, &Value<'_>>, 39 | ) -> zbus::Result<()>; 40 | 41 | /// UnregisterProfile method 42 | fn unregister_profile(&self, profile: &ObjectPath<'_>) -> zbus::Result<()>; 43 | } 44 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/statistics.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Statistics` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Statistics", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Statistics { 27 | /// RefreshRateMs property 28 | #[zbus(property)] 29 | fn refresh_rate_ms(&self) -> zbus::Result; 30 | #[zbus(property)] 31 | fn set_refresh_rate_ms(&self, value: u32) -> zbus::Result<()>; 32 | 33 | /// RxBytes property 34 | #[zbus(property)] 35 | fn rx_bytes(&self) -> zbus::Result; 36 | 37 | /// TxBytes property 38 | #[zbus(property)] 39 | fn tx_bytes(&self) -> zbus::Result; 40 | } 41 | -------------------------------------------------------------------------------- /rs-matter/src/utils/epoch.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 | use core::time::Duration; 19 | 20 | pub type Epoch = fn() -> Duration; 21 | 22 | // As per the spec, if Not After is 0, it should set the time to GeneralizedTime value of 23 | // 99991231235959Z 24 | // So CERT_DOESNT_EXPIRE value is calculated as epoch(99991231235959Z) - MATTER_EPOCH_SECS 25 | pub const MATTER_CERT_DOESNT_EXPIRE: u64 = 252455615999; 26 | 27 | pub const MATTER_EPOCH_SECS: u64 = 946684800; // Seconds from 1970/01/01 00:00:00 till 2000/01/01 00:00:00 UTC 28 | 29 | pub fn dummy_epoch() -> Duration { 30 | Duration::from_secs(0) 31 | } 32 | 33 | #[cfg(feature = "std")] 34 | pub fn sys_epoch() -> Duration { 35 | unwrap!( 36 | std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH), 37 | "System time is before UNIX_EPOCH" 38 | ) 39 | } 40 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/ipvlan.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Ipvlan` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.Ipvlan", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait Ipvlan { 28 | /// Parent property 29 | #[zbus(property)] 30 | fn parent(&self) -> zbus::Result; 31 | 32 | /// Vepa property 33 | #[zbus(property)] 34 | fn vepa(&self) -> zbus::Result; 35 | 36 | /// Mode property 37 | #[zbus(property)] 38 | fn mode(&self) -> zbus::Result; 39 | 40 | /// Private property 41 | #[zbus(property)] 42 | fn private(&self) -> zbus::Result; 43 | } 44 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/macvlan.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Macvlan` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.Macvlan", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait Macvlan { 28 | /// Parent property 29 | #[zbus(property)] 30 | fn parent(&self) -> zbus::Result; 31 | 32 | /// Mode property 33 | #[zbus(property)] 34 | fn mode(&self) -> zbus::Result; 35 | 36 | /// NoPromisc property 37 | #[zbus(property)] 38 | fn no_promisc(&self) -> zbus::Result; 39 | 40 | /// Tap property 41 | #[zbus(property)] 42 | fn tap(&self) -> zbus::Result; 43 | } 44 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/vlan.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Vlan` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.Vlan", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait Vlan { 28 | /// HwAddress property 29 | #[zbus(property)] 30 | fn hw_address(&self) -> zbus::Result; 31 | 32 | /// Carrier property 33 | #[zbus(property)] 34 | fn carrier(&self) -> zbus::Result; 35 | 36 | /// Parent property 37 | #[zbus(property)] 38 | fn parent(&self) -> zbus::Result; 39 | 40 | /// VlanId property 41 | #[zbus(property)] 42 | fn vlan_id(&self) -> zbus::Result; 43 | } 44 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/team.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Team` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.Team", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait Team { 28 | /// HwAddress property 29 | #[zbus(property)] 30 | fn hw_address(&self) -> zbus::Result; 31 | 32 | /// Carrier property 33 | #[zbus(property)] 34 | fn carrier(&self) -> zbus::Result; 35 | 36 | /// Slaves property 37 | #[zbus(property)] 38 | fn slaves(&self) -> zbus::Result>; 39 | 40 | /// Config property 41 | #[zbus(property)] 42 | fn config(&self) -> zbus::Result; 43 | } 44 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/thermometer_manager.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 | //! # D-Bus interface proxy for: `org.bluez.ThermometerManager1` 19 | 20 | use zbus::{proxy, zvariant::ObjectPath}; 21 | 22 | #[proxy(interface = "org.bluez.ThermometerManager1", assume_defaults = true)] 23 | pub trait ThermometerManager { 24 | /// DisableIntermediateMeasurement method 25 | fn disable_intermediate_measurement(&self, agent: &ObjectPath<'_>) -> zbus::Result<()>; 26 | 27 | /// EnableIntermediateMeasurement method 28 | fn enable_intermediate_measurement(&self, agent: &ObjectPath<'_>) -> zbus::Result<()>; 29 | 30 | /// RegisterWatcher method 31 | fn register_watcher(&self, agent: &ObjectPath<'_>) -> zbus::Result<()>; 32 | 33 | /// UnregisterWatcher method 34 | fn unregister_watcher(&self, agent: &ObjectPath<'_>) -> zbus::Result<()>; 35 | } 36 | -------------------------------------------------------------------------------- /rs-matter/src/dm/types.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 | use crate::tlv::ToTLV; 19 | 20 | pub use attribute::*; 21 | pub use cluster::*; 22 | pub use command::*; 23 | pub use dataver::*; 24 | pub use endpoint::*; 25 | pub use handler::*; 26 | pub use metadata::*; 27 | pub use node::*; 28 | pub use privilege::*; 29 | pub use reply::*; 30 | 31 | mod attribute; 32 | mod cluster; 33 | mod command; 34 | mod dataver; 35 | mod endpoint; 36 | mod handler; 37 | mod metadata; 38 | mod node; 39 | mod privilege; 40 | mod reply; 41 | 42 | pub type EndptId = crate::im::EndptId; 43 | pub type ClusterId = crate::im::ClusterId; 44 | pub type AttrId = crate::im::AttrId; 45 | pub type CmdId = crate::im::CmdId; 46 | 47 | #[derive(Debug, ToTLV, Copy, Clone)] 48 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] 49 | pub struct DeviceType { 50 | pub dtype: u16, 51 | pub drev: u16, 52 | } 53 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/dns_manager.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.DnsManager` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::proxy; 23 | use zbus::zvariant::OwnedValue; 24 | 25 | #[proxy( 26 | interface = "org.freedesktop.NetworkManager.DnsManager", 27 | default_service = "org.freedesktop.NetworkManager", 28 | default_path = "/org/freedesktop/NetworkManager/DnsManager" 29 | )] 30 | pub trait DnsManager { 31 | /// Configuration property 32 | #[zbus(property)] 33 | fn configuration(&self) -> zbus::Result>>; 34 | 35 | /// Mode property 36 | #[zbus(property)] 37 | fn mode(&self) -> zbus::Result; 38 | 39 | /// RcManager property 40 | #[zbus(property)] 41 | fn rc_manager(&self) -> zbus::Result; 42 | } 43 | -------------------------------------------------------------------------------- /scripts/memory/memdf/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | orphan: true 3 | --- 4 | 5 | This package contains routines to to collect, aggregate, and report memory 6 | usage, using Pandas `DataFrame` as the primary representation. 7 | 8 | - memdf.collect — Helpers to read memory information from various sources 9 | (e.g. executables) according to command line options. 10 | - memdf.df — `DataFrame` utilities, in particular definitions of columns and 11 | types for the main uses of data frames. 12 | - memdf.name — Names for synthetic symbols, etc. Individual readers are 13 | located under memdf.collector. 14 | - memdf.report — Helpers to write data frames in various formats according to 15 | command line or configured options. 16 | - memdf.select — Helpers to select relevant subsets of data frames according 17 | to command line or configured options. 18 | - memdf.sizedb — Helpers for a database of size information. 19 | 20 | Modules under memdf.util are not specifically tied to memory usage. 21 | 22 | - memdf.util.config — `Config` utility class for managing command line or 23 | other options according to a declarative description. 24 | - memdf.util.github — Utilities for communicating with GitHub. 25 | - memdf.util.markdown — Utilities for manipulating Markdown text. 26 | - memdf.util.nd — Nested dictionary utilities, used by `Config`. 27 | - memdf.util.pretty — Pretty-printed logging utility functions. 28 | - memdf.util.sqlite - Utilities for connecting to a sqlite3 database. 29 | - memdf.util.subprocess — Utilities for executing external commands. 30 | -------------------------------------------------------------------------------- /rs-matter/src/dm/types/dataver.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 | use core::cell::Cell; 19 | use core::num::Wrapping; 20 | 21 | use crate::utils::rand::Rand; 22 | 23 | #[derive(Debug, Clone, Eq, PartialEq)] 24 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] 25 | pub struct Dataver(#[cfg_attr(feature = "defmt", defmt(Debug2Format))] Cell>); 26 | 27 | impl Dataver { 28 | pub fn new_rand(rand: Rand) -> Self { 29 | let mut bytes = [0; 4]; 30 | 31 | rand(&mut bytes); 32 | 33 | Self::new(u32::from_le_bytes(bytes)) 34 | } 35 | 36 | pub const fn new(initial: u32) -> Self { 37 | Self(Cell::new(Wrapping(initial))) 38 | } 39 | 40 | pub fn get(&self) -> u32 { 41 | self.0.get().0 42 | } 43 | 44 | pub fn changed(&self) -> u32 { 45 | self.0.set(self.0.get() + Wrapping(1)); 46 | 47 | self.get() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/avahi/address_resolver.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 | //! # D-Bus interface proxy for: `org.freedesktop.Avahi.AddressResolver` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.Avahi.AddressResolver", 24 | default_service = "org.freedesktop.Avahi" 25 | )] 26 | pub trait AddressResolver { 27 | /// Free method 28 | fn free(&self) -> zbus::Result<()>; 29 | 30 | /// Start method 31 | fn start(&self) -> zbus::Result<()>; 32 | 33 | /// Failure signal 34 | #[zbus(signal)] 35 | fn failure(&self, error: &str) -> zbus::Result<()>; 36 | 37 | /// Found signal 38 | #[zbus(signal)] 39 | fn found( 40 | &self, 41 | interface: i32, 42 | protocol: i32, 43 | aprotocol: i32, 44 | address: &str, 45 | name: &str, 46 | flags: u32, 47 | ) -> zbus::Result<()>; 48 | } 49 | -------------------------------------------------------------------------------- /rs-matter/src/sc/crypto.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 | #[cfg(not(any(feature = "openssl", feature = "mbedtls", feature = "rustcrypto")))] 19 | pub use self::dummy::CryptoSpake2; 20 | #[cfg(all(feature = "mbedtls", target_os = "espidf"))] 21 | pub use self::esp_mbedtls::CryptoSpake2; 22 | #[cfg(all(feature = "mbedtls", not(target_os = "espidf")))] 23 | pub use self::mbedtls::CryptoSpake2; 24 | #[cfg(feature = "openssl")] 25 | pub use self::openssl::CryptoSpake2; 26 | #[cfg(feature = "rustcrypto")] 27 | pub use self::rustcrypto::CryptoSpake2; 28 | 29 | #[cfg(not(any(feature = "openssl", feature = "mbedtls", feature = "rustcrypto")))] 30 | mod dummy; 31 | #[cfg(all(feature = "mbedtls", target_os = "espidf"))] 32 | mod esp_mbedtls; 33 | #[cfg(all(feature = "mbedtls", not(target_os = "espidf")))] 34 | mod mbedtls; 35 | #[cfg(feature = "openssl")] 36 | mod openssl; 37 | #[cfg(feature = "rustcrypto")] 38 | mod rustcrypto; 39 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/avahi/host_name_resolver.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 | //! # D-Bus interface proxy for: `org.freedesktop.Avahi.HostNameResolver` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.Avahi.HostNameResolver", 24 | default_service = "org.freedesktop.Avahi" 25 | )] 26 | pub trait HostNameResolver { 27 | /// Free method 28 | fn free(&self) -> zbus::Result<()>; 29 | 30 | /// Start method 31 | fn start(&self) -> zbus::Result<()>; 32 | 33 | /// Failure signal 34 | #[zbus(signal)] 35 | fn failure(&self, error: &str) -> zbus::Result<()>; 36 | 37 | /// Found signal 38 | #[zbus(signal)] 39 | fn found( 40 | &self, 41 | interface: i32, 42 | protocol: i32, 43 | name: &str, 44 | aprotocol: i32, 45 | address: &str, 46 | flags: u32, 47 | ) -> zbus::Result<()>; 48 | } 49 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/ppp.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.PPP` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::proxy; 23 | use zbus::zvariant::Value; 24 | 25 | #[proxy( 26 | interface = "org.freedesktop.NetworkManager.PPP", 27 | default_service = "org.freedesktop.NetworkManager" 28 | )] 29 | pub trait PPP { 30 | /// NeedSecrets method 31 | fn need_secrets(&self) -> zbus::Result<(String, String)>; 32 | 33 | /// SetIpv4Config method 34 | fn set_ipv4_config(&self, config: HashMap<&str, Value<'_>>) -> zbus::Result<()>; 35 | 36 | /// SetIpv6Config method 37 | fn set_ipv6_config(&self, config: HashMap<&str, Value<'_>>) -> zbus::Result<()>; 38 | 39 | /// SetState method 40 | fn set_state(&self, state: u32) -> zbus::Result<()>; 41 | 42 | /// SetIfindex method 43 | fn set_ifindex(&self, ifindex: i32) -> zbus::Result<()>; 44 | } 45 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/modem.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Modem` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Modem", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Modem { 27 | /// ModemCapabilities property 28 | #[zbus(property)] 29 | fn modem_capabilities(&self) -> zbus::Result; 30 | 31 | /// CurrentCapabilities property 32 | #[zbus(property)] 33 | fn current_capabilities(&self) -> zbus::Result; 34 | 35 | /// DeviceId property 36 | #[zbus(property)] 37 | fn device_id(&self) -> zbus::Result; 38 | 39 | /// OperatorCode property 40 | #[zbus(property)] 41 | fn operator_code(&self) -> zbus::Result; 42 | 43 | /// Apn property 44 | #[zbus(property)] 45 | fn apn(&self) -> zbus::Result; 46 | } 47 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/hsr.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Hsr` 19 | 20 | use zbus::{proxy, zvariant::OwnedObjectPath}; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Hsr", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Hsr { 27 | /// SupervisionAddress property 28 | #[zbus(property)] 29 | fn supervision_address(&self) -> zbus::Result; 30 | 31 | /// Port1 property 32 | #[zbus(property)] 33 | fn port1(&self) -> zbus::Result; 34 | 35 | /// Port2 property 36 | #[zbus(property)] 37 | fn port2(&self) -> zbus::Result; 38 | 39 | /// MulticastSpec property 40 | #[zbus(property)] 41 | fn multicast_spec(&self) -> zbus::Result; 42 | 43 | /// Prp property 44 | #[zbus(property)] 45 | fn prp(&self) -> zbus::Result; 46 | } 47 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/wired.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Wired` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Wired", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Wired { 27 | /// Carrier property 28 | #[zbus(property)] 29 | fn carrier(&self) -> zbus::Result; 30 | 31 | /// HwAddress property 32 | #[zbus(property)] 33 | fn hw_address(&self) -> zbus::Result; 34 | 35 | /// PermHwAddress property 36 | #[zbus(property)] 37 | fn perm_hw_address(&self) -> zbus::Result; 38 | 39 | /// S390Subchannels property 40 | #[zbus(property, name = "S390Subchannels")] 41 | fn s390subchannels(&self) -> zbus::Result>; 42 | 43 | /// Speed property 44 | #[zbus(property)] 45 | fn speed(&self) -> zbus::Result; 46 | } 47 | -------------------------------------------------------------------------------- /rs-matter/src/utils/sync/notification.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 | use embassy_sync::blocking_mutex::raw::RawMutex; 19 | 20 | use super::signal::Signal; 21 | 22 | /// A notification primitive that allows for notifying a single waiter. 23 | pub struct Notification(Signal>); 24 | 25 | impl Default for Notification 26 | where 27 | M: RawMutex, 28 | { 29 | fn default() -> Self { 30 | Self::new() 31 | } 32 | } 33 | 34 | impl Notification 35 | where 36 | M: RawMutex, 37 | { 38 | /// Create a new `Notification`. 39 | pub const fn new() -> Self { 40 | Self(Signal::new(None)) 41 | } 42 | 43 | /// Notify the waiter. 44 | pub fn notify(&self) { 45 | self.0.modify(|state| { 46 | *state = Some(()); 47 | (true, ()) 48 | }); 49 | } 50 | 51 | /// Wait for the notification. 52 | pub async fn wait(&self) { 53 | self.0.wait(|state| state.take()).await; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/health_device.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 | //! # D-Bus interface proxy for: `org.bluez.HealthDevice1` 19 | 20 | use zbus::{ 21 | proxy, 22 | zvariant::{ObjectPath, OwnedObjectPath}, 23 | }; 24 | 25 | #[proxy(interface = "org.bluez.HealthDevice1", assume_defaults = true)] 26 | pub trait HealthDevice { 27 | /// ChannelConnected method 28 | fn channel_connected(&self, channel: &ObjectPath<'_>) -> zbus::Result<()>; 29 | 30 | /// ChannelDeleted method 31 | fn channel_deleted(&self, channel: &ObjectPath<'_>) -> zbus::Result<()>; 32 | 33 | /// CreateChannel method 34 | fn create_channel( 35 | &self, 36 | application: &ObjectPath<'_>, 37 | configuration: &str, 38 | ) -> zbus::Result; 39 | 40 | /// DestroyChannel method 41 | fn destroy_channel(&self, channel: &ObjectPath<'_>) -> zbus::Result<()>; 42 | 43 | /// Echo method 44 | fn echo(&self) -> zbus::Result; 45 | } 46 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/gatt_descriptor.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 | //! # D-Bus interface proxy for: `org.bluez.GattDescriptor1` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::{ 23 | proxy, 24 | zvariant::{OwnedObjectPath, Value}, 25 | }; 26 | 27 | #[proxy(interface = "org.bluez.GattDescriptor1", assume_defaults = true)] 28 | pub trait GattDescriptor { 29 | /// ReadValue method 30 | fn read_value(&self, options: HashMap<&str, &Value<'_>>) -> zbus::Result>; 31 | 32 | /// WriteValue method 33 | fn write_value(&self, value: &[u8], options: HashMap<&str, &Value<'_>>) -> zbus::Result<()>; 34 | 35 | /// Characteristic property 36 | #[zbus(property)] 37 | fn characteristic(&self) -> zbus::Result; 38 | 39 | /// UUID property 40 | #[zbus(property, name = "UUID")] 41 | fn uuid(&self) -> zbus::Result; 42 | 43 | /// Value property 44 | #[zbus(property)] 45 | fn value(&self) -> zbus::Result>; 46 | } 47 | -------------------------------------------------------------------------------- /rs-matter/src/im/timed.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 | //! This module contains types related to the Timed Request feature in the Matter Interaction Model. 19 | 20 | use core::time::Duration; 21 | 22 | use crate::tlv::{FromTLV, ToTLV}; 23 | use crate::utils::epoch::Epoch; 24 | 25 | /// A structure representing a timed request in the Interaction Model. 26 | /// 27 | /// Corresponds to the `TimedRequestMessage` struct in the Interaction Model. 28 | #[derive(Default, Debug, Clone, PartialEq, Eq, Hash, FromTLV, ToTLV)] 29 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] 30 | pub struct TimedReq { 31 | /// The timeout duration in milliseconds for the request. 32 | pub timeout: u16, 33 | } 34 | 35 | impl TimedReq { 36 | /// Returns the moment in time - since the system epoch - when the request 37 | /// following this timed request should be considered expired. 38 | pub fn timeout_instant(&self, epoch: Epoch) -> Duration { 39 | unwrap!(epoch().checked_add(Duration::from_millis(self.timeout as _))) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/avahi/service_resolver.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 | //! # D-Bus interface proxy for: `org.freedesktop.Avahi.ServiceResolver` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.Avahi.ServiceResolver", 24 | default_service = "org.freedesktop.Avahi" 25 | )] 26 | pub trait ServiceResolver { 27 | /// Free method 28 | fn free(&self) -> zbus::Result<()>; 29 | 30 | /// Start method 31 | fn start(&self) -> zbus::Result<()>; 32 | 33 | /// Failure signal 34 | #[zbus(signal)] 35 | fn failure(&self, error: &str) -> zbus::Result<()>; 36 | 37 | /// Found signal 38 | #[zbus(signal)] 39 | fn found( 40 | &self, 41 | interface: i32, 42 | protocol: i32, 43 | name: &str, 44 | type_: &str, 45 | domain: &str, 46 | host: &str, 47 | aprotocol: i32, 48 | address: &str, 49 | port: u16, 50 | txt: Vec>, 51 | flags: u32, 52 | ) -> zbus::Result<()>; 53 | } 54 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/wpa_supp/network.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 | //! # D-Bus interface proxy for: `fi.w1.wpa_supplicant1.Interface.Network` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::proxy; 23 | use zbus::zvariant::{OwnedValue, Value}; 24 | 25 | #[proxy( 26 | interface = "fi.w1.wpa_supplicant1.Network", 27 | default_service = "fi.w1.wpa_supplicant1" 28 | )] 29 | pub trait Network { 30 | /// PropertiesChanged signal 31 | #[zbus(signal)] 32 | fn properties_changed(&self, properties: HashMap<&str, Value<'_>>) -> zbus::Result<()>; 33 | 34 | /// Enabled property 35 | #[zbus(property)] 36 | fn enabled(&self) -> zbus::Result; 37 | #[zbus(property)] 38 | fn set_enabled(&self, enabled: bool) -> zbus::Result<()>; 39 | 40 | /// Properties property 41 | #[zbus(property, name = "Properties")] 42 | fn props(&self) -> zbus::Result>; 43 | #[zbus(property, name = "Properties")] 44 | fn set_props(&self, properties: HashMap<&str, Value<'_>>) -> zbus::Result<()>; 45 | } 46 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/tun.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Tun` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.Device.Tun", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait Tun { 27 | /// Owner property 28 | #[zbus(property)] 29 | fn owner(&self) -> zbus::Result; 30 | 31 | /// Group 32 | #[zbus(property)] 33 | fn group(&self) -> zbus::Result; 34 | 35 | /// Mode property 36 | #[zbus(property)] 37 | fn mode(&self) -> zbus::Result; 38 | 39 | /// NoPi property 40 | #[zbus(property)] 41 | fn no_pi(&self) -> zbus::Result; 42 | 43 | /// VnetHdr property 44 | #[zbus(property)] 45 | fn vnet_hdr(&self) -> zbus::Result; 46 | 47 | /// MultiQueue property 48 | #[zbus(property)] 49 | fn multi_queue(&self) -> zbus::Result; 50 | 51 | /// HwAddress property 52 | #[zbus(property)] 53 | fn hw_address(&self) -> zbus::Result; 54 | } 55 | -------------------------------------------------------------------------------- /rs-matter/src/transport/network/udp.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 | #![cfg(all(feature = "std", feature = "async-io"))] 19 | 20 | //! UDP transport implementation for async-io 21 | 22 | use crate::error::*; 23 | 24 | use std::net::UdpSocket; 25 | 26 | use async_io::Async; 27 | 28 | use crate::transport::network::Address; 29 | 30 | use super::{NetworkReceive, NetworkSend}; 31 | 32 | impl NetworkSend for &Async { 33 | async fn send_to(&mut self, data: &[u8], addr: Address) -> Result<(), Error> { 34 | Async::::send_to(self, data, addr.udp().ok_or(ErrorCode::NoNetworkInterface)?) 35 | .await?; 36 | 37 | Ok(()) 38 | } 39 | } 40 | 41 | impl NetworkReceive for &Async { 42 | async fn wait_available(&mut self) -> Result<(), Error> { 43 | Async::::readable(self).await?; 44 | 45 | Ok(()) 46 | } 47 | 48 | async fn recv_from(&mut self, buffer: &mut [u8]) -> Result<(usize, Address), Error> { 49 | let (len, addr) = Async::::recv_from(self, buffer).await?; 50 | 51 | Ok((len, Address::Udp(addr))) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /rs-matter/src/utils/iter.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 | /// An extension trait for `Iterator` implementing several utility methods. 19 | pub trait TryFindIterator: Iterator> + Sized { 20 | /// Find the first element that satisfies the supplied `predicate`. 21 | /// 22 | /// Method name is `do_try_find` to avoid collissions with `Iterator::try_find` 23 | /// once it gets stabilized. 24 | fn do_try_find

(self, mut predicate: P) -> Result, E> 25 | where 26 | P: FnMut(&T) -> Result, 27 | { 28 | for val in self { 29 | let val = val?; 30 | 31 | let result = predicate(&val); 32 | match result { 33 | Ok(matches) => { 34 | if matches { 35 | return Ok(Some(val)); 36 | } 37 | } 38 | Err(err) => { 39 | return Err(err); 40 | } 41 | } 42 | } 43 | 44 | Ok(None) 45 | } 46 | } 47 | 48 | impl TryFindIterator for I where I: Iterator> {} 49 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/wifi_p2p.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.WifiP2P` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::proxy; 23 | use zbus::zvariant::{ObjectPath, OwnedObjectPath, Value}; 24 | 25 | #[proxy( 26 | interface = "org.freedesktop.NetworkManager.Device.WifiP2P", 27 | default_service = "org.freedesktop.NetworkManager" 28 | )] 29 | pub trait WifiP2P { 30 | /// StartFind method 31 | fn start_find(&self, options: HashMap<&str, &Value<'_>>) -> zbus::Result<()>; 32 | 33 | /// StopFind method 34 | fn stop_find(&self) -> zbus::Result<()>; 35 | 36 | /// PeerAdded signal 37 | #[zbus(signal)] 38 | fn peer_added(&self, peer: ObjectPath<'_>) -> zbus::Result<()>; 39 | 40 | /// PeerRemoved signal 41 | #[zbus(signal)] 42 | fn peer_removed(&self, peer: ObjectPath<'_>) -> zbus::Result<()>; 43 | 44 | /// HwAddress property 45 | #[zbus(property)] 46 | fn hw_address(&self) -> zbus::Result; 47 | 48 | /// Peers property 49 | #[zbus(property)] 50 | fn peers(&self) -> zbus::Result>; 51 | } 52 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/agent.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 | //! # D-Bus interface proxy for: `org.bluez.Agent1` 19 | 20 | use zbus::{proxy, zvariant::ObjectPath}; 21 | 22 | #[proxy(interface = "org.bluez.Agent1", assume_defaults = true)] 23 | pub trait Agent { 24 | /// AuthorizeService method 25 | fn authorize_service(&self, device: &ObjectPath<'_>, uuid: &str) -> zbus::Result<()>; 26 | 27 | /// Cancel method 28 | fn cancel(&self) -> zbus::Result<()>; 29 | 30 | /// DisplayPinCode method 31 | fn display_pin_code(&self, device: &ObjectPath<'_>, pincode: &str) -> zbus::Result<()>; 32 | 33 | /// Release method 34 | fn release(&self) -> zbus::Result<()>; 35 | 36 | /// RequestAuthorization method 37 | fn request_authorization(&self, device: &ObjectPath<'_>) -> zbus::Result<()>; 38 | 39 | /// RequestConfirmation method 40 | fn request_confirmation(&self, device: &ObjectPath<'_>) -> zbus::Result<()>; 41 | 42 | /// RequestPasskey method 43 | fn request_passkey(&self, device: &ObjectPath<'_>) -> zbus::Result<()>; 44 | 45 | /// RequestPinCode method 46 | fn request_pin_code(&self, device: &ObjectPath<'_>) -> zbus::Result; 47 | } 48 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/avahi/domain_browser.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 | //! # D-Bus interface proxy for: `org.freedesktop.Avahi.DomainBrowser` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.Avahi.DomainBrowser", 24 | default_service = "org.freedesktop.Avahi" 25 | )] 26 | pub trait DomainBrowser { 27 | /// Free method 28 | fn free(&self) -> zbus::Result<()>; 29 | 30 | /// Start method 31 | fn start(&self) -> zbus::Result<()>; 32 | 33 | /// AllForNow signal 34 | #[zbus(signal)] 35 | fn all_for_now(&self) -> zbus::Result<()>; 36 | 37 | /// CacheExhausted signal 38 | #[zbus(signal)] 39 | fn cache_exhausted(&self) -> zbus::Result<()>; 40 | 41 | /// Failure signal 42 | #[zbus(signal)] 43 | fn failure(&self, error: &str) -> zbus::Result<()>; 44 | 45 | /// ItemNew signal 46 | #[zbus(signal)] 47 | fn item_new(&self, interface: i32, protocol: i32, domain: &str, flags: u32) 48 | -> zbus::Result<()>; 49 | 50 | /// ItemRemove signal 51 | #[zbus(signal)] 52 | fn item_remove( 53 | &self, 54 | interface: i32, 55 | protocol: i32, 56 | domain: &str, 57 | flags: u32, 58 | ) -> zbus::Result<()>; 59 | } 60 | -------------------------------------------------------------------------------- /rs-matter/src/dm/clusters/dev_att.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 | use crate::error::Error; 19 | 20 | /// Device Attestation Data Type 21 | #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] 22 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] 23 | pub enum DataType { 24 | /// Certificate Declaration 25 | CertDeclaration, 26 | /// Product Attestation Intermediary Certificate 27 | PAI, 28 | /// Device Attestation Certificate 29 | DAC, 30 | /// Device Attestation Certificate - Public Key 31 | DACPubKey, 32 | /// Device Attestation Certificate - Private Key 33 | DACPrivKey, 34 | } 35 | 36 | /// The Device Attestation Data Fetcher Trait 37 | /// 38 | /// Objects that implement this trait allow the Matter subsystem to query the object 39 | /// for the Device Attestation data that is programmed in the Matter device. 40 | pub trait DevAttDataFetcher { 41 | /// Get the data in the provided buffer 42 | fn get_devatt_data(&self, data_type: DataType, buf: &mut [u8]) -> Result; 43 | } 44 | 45 | impl DevAttDataFetcher for &T 46 | where 47 | T: DevAttDataFetcher, 48 | { 49 | fn get_devatt_data(&self, data_type: DataType, buf: &mut [u8]) -> Result { 50 | (*self).get_devatt_data(data_type, buf) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /rs-matter/src/dm/clusters.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 | //! This module imports all system clusters that are used by the `rs-matter` itself. 19 | //! 20 | //! Additionally, it imports the following extra ones: 21 | //! - OnOff - for demoing purposes 22 | //! - UnitTesting - for testing purposes 23 | 24 | pub mod acl; 25 | pub mod adm_comm; 26 | pub mod basic_info; 27 | pub mod desc; 28 | pub mod dev_att; 29 | pub mod eth_diag; 30 | pub mod gen_comm; 31 | pub mod gen_diag; 32 | pub mod grp_key_mgmt; 33 | pub mod level_control; 34 | pub mod net_comm; 35 | pub mod noc; 36 | pub mod on_off; 37 | pub mod thread_diag; 38 | pub mod unit_testing; 39 | pub mod wifi_diag; 40 | 41 | /// This module imports all system clusters that are used by the `rs-matter` itself. 42 | pub mod decl { 43 | crate::import!( 44 | AdministratorCommissioning, 45 | AccessControl, 46 | BasicInformation, 47 | Descriptor, 48 | EthernetNetworkDiagnostics, 49 | GeneralDiagnostics, 50 | GeneralCommissioning, 51 | GroupKeyManagement, 52 | LevelControl, 53 | NetworkCommissioning, 54 | OnOff, 55 | OperationalCredentials, 56 | ThreadNetworkDiagnostics, 57 | UnitTesting, 58 | WiFiNetworkDiagnostics, 59 | ); 60 | } 61 | -------------------------------------------------------------------------------- /.github/workflows/bloat-check.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020-2025 Project CHIP Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Bloat Check 16 | on: 17 | workflow_dispatch: 18 | schedule: 19 | - cron: "*/5 * * * *" 20 | 21 | concurrency: 22 | group: ${{ github.workflow }} 23 | # Don't cancel an already-running bloat check just because it took more 24 | # than 5 minutes to run and our cron job is trying to schedule a new one. 25 | cancel-in-progress: false 26 | 27 | jobs: 28 | pull_request_update: 29 | name: Report on pull requests 30 | 31 | # Don't run on forked repos 32 | if: github.repository_owner == 'project-chip' 33 | 34 | runs-on: ubuntu-latest 35 | 36 | steps: 37 | - name: Checkout 38 | uses: actions/checkout@v5 39 | - name: Set up environment for size reports 40 | uses: ./.github/actions/setup-size-reports 41 | if: ${{ !env.ACT }} 42 | with: 43 | gh-context: ${{ toJson(github) }} 44 | - name: Report 45 | run: | 46 | python scripts/memory/gh_report.py \ 47 | --verbose \ 48 | --report-increases 0.2 \ 49 | --report-pr \ 50 | --github-comment \ 51 | --github-limit-artifact-pages 50 \ 52 | --github-limit-artifacts 500 \ 53 | --github-limit-comments 20 \ 54 | --github-repository project-chip/rs-matter \ 55 | --github-api-token "${{ secrets.GITHUB_TOKEN }}" -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/le_advertising_manager.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 | //! # D-Bus interface proxy for: `org.bluez.LEAdvertisingManager1` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::{ 23 | proxy, 24 | zvariant::{ObjectPath, Value}, 25 | }; 26 | 27 | #[proxy( 28 | interface = "org.bluez.LEAdvertisingManager1", 29 | default_service = "org.bluez" 30 | )] 31 | pub trait LEAdvertisingManager { 32 | /// RegisterAdvertisement method 33 | fn register_advertisement( 34 | &self, 35 | advertisement: &ObjectPath<'_>, 36 | options: HashMap<&str, &Value<'_>>, 37 | ) -> zbus::Result<()>; 38 | 39 | /// UnregisterAdvertisement method 40 | fn unregister_advertisement(&self, service: &ObjectPath<'_>) -> zbus::Result<()>; 41 | 42 | /// ActiveInstances property 43 | #[zbus(property)] 44 | fn active_instances(&self) -> zbus::Result; 45 | 46 | /// SupportedIncludes property 47 | #[zbus(property)] 48 | fn supported_includes(&self) -> zbus::Result>; 49 | 50 | /// SupportedInstances property 51 | #[zbus(property)] 52 | fn supported_instances(&self) -> zbus::Result; 53 | 54 | /// SupportedSecondaryChannels property 55 | #[zbus(property)] 56 | fn supported_secondary_channels(&self) -> zbus::Result>; 57 | } 58 | -------------------------------------------------------------------------------- /.github/workflows/size-check.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | schedule: 9 | - cron: "50 6 * * *" 10 | workflow_dispatch: 11 | 12 | env: 13 | RUST_TOOLCHAIN: stable 14 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 15 | CARGO_TERM_COLOR: always 16 | 17 | jobs: 18 | build_and_run_size_report: 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - name: Rust 23 | uses: dtolnay/rust-toolchain@v1 24 | with: 25 | toolchain: ${{ env.RUST_TOOLCHAIN }} 26 | components: rustfmt, clippy, rust-src 27 | 28 | - name: Setup | Rust no-std target 29 | run: rustup target add riscv32imac-unknown-none-elf 30 | 31 | - name: Install libdbus 32 | run: sudo apt-get install -y libdbus-1-dev 33 | 34 | - name: Checkout 35 | uses: actions/checkout@v3 36 | 37 | - name: Set up environment for size reports 38 | uses: ./.github/actions/setup-size-reports 39 | if: ${{ !env.ACT }} 40 | with: 41 | gh-context: ${{ toJson(github) }} 42 | 43 | - name: Examples 44 | run: cargo build --release --no-default-features --features os,rustcrypto,log 45 | 46 | - name: Prepare bloat report from the previous builds 47 | run: | 48 | python scripts/memory/gh_sizes.py \ 49 | linux rs-matter onoff-light \ 50 | target/release/onoff_light \ 51 | /tmp/bloat_reports/ 52 | python scripts/memory/gh_sizes.py \ 53 | linux rs-matter dimmable_light \ 54 | target/release/dimmable_light \ 55 | /tmp/bloat_reports/ 56 | python scripts/memory/gh_sizes.py \ 57 | linux rs-matter speaker \ 58 | target/release/speaker \ 59 | /tmp/bloat_reports/ 60 | 61 | - name: Uploading Size Reports 62 | uses: ./.github/actions/upload-size-reports 63 | if: ${{ !env.ACT }} 64 | with: 65 | platform-name: linux -------------------------------------------------------------------------------- /scripts/memory/report_summary.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2021 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 | """Generate a summary of memory use. 18 | 19 | This program reads memory usage information produces aggregated totals 20 | according to the `--report-by` option: 21 | * `--report-by section` (the default) aggregates memory usage by section. 22 | * `--report-by region` aggregates memory usage by region. A region is a 23 | configuration-defined group of sections. 24 | 25 | Use `--collect-method=help` to see available collection methods. 26 | Use `--output-format=help` to see available output formats. 27 | """ 28 | 29 | import sys 30 | 31 | import memdf.collect 32 | import memdf.report 33 | import memdf.select 34 | from memdf import Config, DFs, SymbolDF 35 | 36 | 37 | def main(argv): 38 | status = 0 39 | try: 40 | config: Config = memdf.collect.parse_args( 41 | { 42 | **memdf.select.CONFIG, 43 | **memdf.report.REPORT_CONFIG, 44 | **memdf.report.REPORT_BY_CONFIG, 45 | **memdf.report.OUTPUT_CONFIG, 46 | }, argv) 47 | dfs: DFs = memdf.collect.collect_files(config) 48 | 49 | symbols = dfs[SymbolDF.name] 50 | summary = memdf.select.groupby(config, symbols) 51 | memdf.report.write_dfs(config, {SymbolDF.name: summary}) 52 | 53 | except Exception as exception: 54 | raise exception 55 | 56 | return status 57 | 58 | 59 | if __name__ == '__main__': 60 | sys.exit(main(sys.argv)) -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/avahi/service_type_browser.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 | //! # D-Bus interface proxy for: `org.freedesktop.Avahi.ServiceTypeBrowser` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.Avahi.ServiceTypeBrowser", 24 | default_service = "org.freedesktop.Avahi" 25 | )] 26 | pub trait ServiceTypeBrowser { 27 | /// Free method 28 | fn free(&self) -> zbus::Result<()>; 29 | 30 | /// Start method 31 | fn start(&self) -> zbus::Result<()>; 32 | 33 | /// AllForNow signal 34 | #[zbus(signal)] 35 | fn all_for_now(&self) -> zbus::Result<()>; 36 | 37 | /// CacheExhausted signal 38 | #[zbus(signal)] 39 | fn cache_exhausted(&self) -> zbus::Result<()>; 40 | 41 | /// Failure signal 42 | #[zbus(signal)] 43 | fn failure(&self, error: &str) -> zbus::Result<()>; 44 | 45 | /// ItemNew signal 46 | #[zbus(signal)] 47 | fn item_new( 48 | &self, 49 | interface: i32, 50 | protocol: i32, 51 | type_: &str, 52 | domain: &str, 53 | flags: u32, 54 | ) -> zbus::Result<()>; 55 | 56 | /// ItemRemove signal 57 | #[zbus(signal)] 58 | fn item_remove( 59 | &self, 60 | interface: i32, 61 | protocol: i32, 62 | type_: &str, 63 | domain: &str, 64 | flags: u32, 65 | ) -> zbus::Result<()>; 66 | } 67 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/avahi/service_browser.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 | //! # D-Bus interface proxy for: `org.freedesktop.Avahi.ServiceBrowser` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.Avahi.ServiceBrowser", 24 | default_service = "org.freedesktop.Avahi" 25 | )] 26 | pub trait ServiceBrowser { 27 | /// Free method 28 | fn free(&self) -> zbus::Result<()>; 29 | 30 | /// Start method 31 | fn start(&self) -> zbus::Result<()>; 32 | 33 | /// AllForNow signal 34 | #[zbus(signal)] 35 | fn all_for_now(&self) -> zbus::Result<()>; 36 | 37 | /// CacheExhausted signal 38 | #[zbus(signal)] 39 | fn cache_exhausted(&self) -> zbus::Result<()>; 40 | 41 | /// Failure signal 42 | #[zbus(signal)] 43 | fn failure(&self, error: &str) -> zbus::Result<()>; 44 | 45 | /// ItemNew signal 46 | #[zbus(signal)] 47 | fn item_new( 48 | &self, 49 | interface: i32, 50 | protocol: i32, 51 | name: &str, 52 | type_: &str, 53 | domain: &str, 54 | flags: u32, 55 | ) -> zbus::Result<()>; 56 | 57 | /// ItemRemove signal 58 | #[zbus(signal)] 59 | fn item_remove( 60 | &self, 61 | interface: i32, 62 | protocol: i32, 63 | name: &str, 64 | type_: &str, 65 | domain: &str, 66 | flags: u32, 67 | ) -> zbus::Result<()>; 68 | } 69 | -------------------------------------------------------------------------------- /rs-matter/src/utils/ipv6.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 | use core::net::Ipv6Addr; 19 | 20 | /// Create a link-local IPv6 address from a MAC address. 21 | /// 22 | /// Note that this function does not perform any SLAAC-related operations 23 | /// like checking whether the generated address is already in use. 24 | pub fn create_link_local_ipv6(mac: &[u8; 6]) -> Ipv6Addr { 25 | Ipv6Addr::new( 26 | 0xfe80, 27 | 0, 28 | 0, 29 | 0, 30 | u16::from_be_bytes([mac[0] ^ 0x02, mac[1]]), 31 | u16::from_be_bytes([mac[2], 0xff]), 32 | u16::from_be_bytes([0xfe, mac[3]]), 33 | u16::from_be_bytes([mac[4], mac[5]]), 34 | ) 35 | } 36 | 37 | #[cfg(test)] 38 | mod tests { 39 | use super::*; 40 | 41 | use crate::alloc::string::ToString; 42 | 43 | extern crate alloc; 44 | 45 | #[test] 46 | fn test_create_link_local_ipv6() { 47 | let mac = [0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc]; 48 | let ipv6 = create_link_local_ipv6(&mac); 49 | assert_eq!(ipv6.to_string(), "fe80::1034:56ff:fe78:9abc"); 50 | 51 | let mac2 = [0x00, 0x11, 0x22, 0x33, 0x44, 0x55]; 52 | let ipv6_2 = create_link_local_ipv6(&mac2); 53 | assert_eq!(ipv6_2.to_string(), "fe80::211:22ff:fe33:4455"); 54 | 55 | let mac3 = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06]; 56 | let ipv6_3 = create_link_local_ipv6(&mac3); 57 | assert_eq!(ipv6_3.to_string(), "fe80::302:3ff:fe04:506"); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/avahi/record_browser.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 | //! # D-Bus interface proxy for: `org.freedesktop.Avahi.RecordBrowser` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.Avahi.RecordBrowser", 24 | default_service = "org.freedesktop.Avahi" 25 | )] 26 | pub trait RecordBrowser { 27 | /// Free method 28 | fn free(&self) -> zbus::Result<()>; 29 | 30 | /// Start method 31 | fn start(&self) -> zbus::Result<()>; 32 | 33 | /// AllForNow signal 34 | #[zbus(signal)] 35 | fn all_for_now(&self) -> zbus::Result<()>; 36 | 37 | /// CacheExhausted signal 38 | #[zbus(signal)] 39 | fn cache_exhausted(&self) -> zbus::Result<()>; 40 | 41 | /// Failure signal 42 | #[zbus(signal)] 43 | fn failure(&self, error: &str) -> zbus::Result<()>; 44 | 45 | /// ItemNew signal 46 | #[zbus(signal)] 47 | fn item_new( 48 | &self, 49 | interface: i32, 50 | protocol: i32, 51 | name: &str, 52 | clazz: u16, 53 | type_: u16, 54 | rdata: Vec, 55 | flags: u32, 56 | ) -> zbus::Result<()>; 57 | 58 | /// ItemRemove signal 59 | #[zbus(signal)] 60 | fn item_remove( 61 | &self, 62 | interface: i32, 63 | protocol: i32, 64 | name: &str, 65 | clazz: u16, 66 | type_: u16, 67 | rdata: Vec, 68 | flags: u32, 69 | ) -> zbus::Result<()>; 70 | } 71 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/wifi_p2ppeer.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.AccessPoint` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.WifiP2PPeer", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait WifiP2PPeer { 27 | /// Name property 28 | #[zbus(property)] 29 | fn name(&self) -> zbus::Result; 30 | 31 | /// Flags property 32 | #[zbus(property)] 33 | fn flags(&self) -> zbus::Result; 34 | 35 | /// Manufacturer property 36 | #[zbus(property)] 37 | fn manufacturer(&self) -> zbus::Result; 38 | 39 | /// Model property 40 | #[zbus(property)] 41 | fn model(&self) -> zbus::Result; 42 | 43 | /// ModelNumber property 44 | #[zbus(property)] 45 | fn model_number(&self) -> zbus::Result; 46 | 47 | /// Serial property 48 | #[zbus(property)] 49 | fn serial(&self) -> zbus::Result; 50 | 51 | /// WfdIEs property 52 | #[zbus(property)] 53 | fn wfd_ies(&self) -> zbus::Result>; 54 | 55 | /// HwAddress property 56 | #[zbus(property)] 57 | fn hw_address(&self) -> zbus::Result; 58 | 59 | /// Strength property 60 | #[zbus(property)] 61 | fn strength(&self) -> zbus::Result; 62 | 63 | /// LastSeen property 64 | #[zbus(property)] 65 | fn last_seen(&self) -> zbus::Result; 66 | } 67 | -------------------------------------------------------------------------------- /rs-matter/src/dm/clusters/eth_diag.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2023 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 | //! This module contains the implementation of the Ethernet Network Diagnostics cluster and its handler. 19 | 20 | use crate::dm::{Cluster, Dataver, InvokeContext}; 21 | use crate::error::{Error, ErrorCode}; 22 | use crate::with; 23 | 24 | pub use crate::dm::clusters::decl::ethernet_network_diagnostics::*; 25 | 26 | /// The system implementation of a handler for the Ethernet Network Diagnostics Matter cluster. 27 | #[derive(Debug, Clone)] 28 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] 29 | pub struct EthDiagHandler { 30 | dataver: Dataver, 31 | } 32 | 33 | impl EthDiagHandler { 34 | /// Create a new instance of `EthDiagHandler` with the given `Dataver`. 35 | pub const fn new(dataver: Dataver) -> Self { 36 | Self { dataver } 37 | } 38 | 39 | /// Adapt the handler instance to the generic `rs-matter` `Handler` trait 40 | pub const fn adapt(self) -> HandlerAdaptor { 41 | HandlerAdaptor(self) 42 | } 43 | } 44 | 45 | impl ClusterHandler for EthDiagHandler { 46 | const CLUSTER: Cluster<'static> = FULL_CLUSTER.with_attrs(with!(required)).with_cmds(with!()); 47 | 48 | fn dataver(&self) -> u32 { 49 | self.dataver.get() 50 | } 51 | 52 | fn dataver_changed(&self) { 53 | self.dataver.changed(); 54 | } 55 | 56 | fn handle_reset_counts(&self, _ctx: impl InvokeContext) -> Result<(), Error> { 57 | Err(ErrorCode::InvalidAction.into()) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez.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 | //! zbus proxies for BlueZ. 19 | //! 20 | //! All proxy traits are either: 21 | //! - Generated using introspection (i.e. `zbus-xmlgen system zbus-xmlgen system org.bluez /org/bluez`) 22 | //! - ... or by introspecting predefined introspection XML files from here: https://github.com/bluez-rs/bluez-async/tree/main/bluez-generated/specs 23 | //! - ... or manually by consulting the BlueZ D-Bus interface definitions as documented here: 24 | //! https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc circa 2025-07-15 25 | //! - ... or by running the `bluezapi2qt` tool from https://github.com/KDE/bluez-qt/tree/master/tools/bluezapi2qt on the ".txt" BlueZ API definitions 26 | //! as available in the BlueZ GIT repo from above until commit hash 85460c32d1334f5edad021d214eb997e6f462b30 27 | 28 | pub mod adapter; 29 | pub mod admin_policy_set; 30 | pub mod agent; 31 | pub mod agent_manager; 32 | pub mod battery; 33 | pub mod battery_provider_manager; 34 | pub mod device; 35 | pub mod gatt_characteristic; 36 | pub mod gatt_descriptor; 37 | pub mod gatt_manager; 38 | pub mod gatt_profile; 39 | pub mod gatt_service; 40 | pub mod health_device; 41 | pub mod health_manager; 42 | pub mod le_advertisement; 43 | pub mod le_advertising_manager; 44 | pub mod media; 45 | pub mod media_control; 46 | pub mod network; 47 | pub mod network_server; 48 | pub mod profile_manager; 49 | pub mod sim_access; 50 | pub mod thermometer_manager; 51 | pub mod thermometer_watcher; 52 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/media.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 | //! # D-Bus interface proxy for: `org.bluez.Media1` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::{ 23 | proxy, 24 | zvariant::{ObjectPath, Value}, 25 | }; 26 | 27 | #[proxy(interface = "org.bluez.Media1", default_service = "org.bluez")] 28 | pub trait Media { 29 | /// RegisterApplication method 30 | fn register_application( 31 | &self, 32 | application: &ObjectPath<'_>, 33 | options: HashMap<&str, &Value<'_>>, 34 | ) -> zbus::Result<()>; 35 | 36 | /// RegisterEndpoint method 37 | fn register_endpoint( 38 | &self, 39 | endpoint: &ObjectPath<'_>, 40 | properties: HashMap<&str, &Value<'_>>, 41 | ) -> zbus::Result<()>; 42 | 43 | /// RegisterPlayer method 44 | fn register_player( 45 | &self, 46 | player: &ObjectPath<'_>, 47 | properties: HashMap<&str, &Value<'_>>, 48 | ) -> zbus::Result<()>; 49 | 50 | /// UnregisterApplication method 51 | fn unregister_application(&self, application: &ObjectPath<'_>) -> zbus::Result<()>; 52 | 53 | /// UnregisterEndpoint method 54 | fn unregister_endpoint(&self, endpoint: &ObjectPath<'_>) -> zbus::Result<()>; 55 | 56 | /// UnregisterPlayer method 57 | fn unregister_player(&self, player: &ObjectPath<'_>) -> zbus::Result<()>; 58 | 59 | /// SupportedUUIDs property 60 | #[zbus(property, name = "SupportedUUIDs")] 61 | fn supported_uuids(&self) -> zbus::Result>; 62 | } 63 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/wpa_supp/wps.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 | //! # D-Bus interface proxy for: `fi.w1.wpa_supplicant1.Interface.WPS` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::proxy; 23 | use zbus::zvariant::{OwnedValue, Value}; 24 | 25 | #[proxy( 26 | interface = "fi.w1.wpa_supplicant1.Interface.WPS", 27 | default_service = "fi.w1.wpa_supplicant1" 28 | )] 29 | pub trait WPS { 30 | /// Start method 31 | fn start(&self, args: HashMap<&str, &Value<'_>>) -> zbus::Result>; 32 | 33 | /// Cancel method 34 | fn cancel(&self) -> zbus::Result<()>; 35 | 36 | /// Credentials signal 37 | #[zbus(signal)] 38 | fn credentials(&self, credentials: HashMap<&str, Value<'_>>) -> zbus::Result<()>; 39 | 40 | /// Event signal 41 | #[zbus(signal)] 42 | fn event(&self, name: &str, args: HashMap<&str, Value<'_>>) -> zbus::Result<()>; 43 | 44 | /// PropertiesChanged signal 45 | #[zbus(signal)] 46 | fn properties_changed(&self, properties: HashMap<&str, Value<'_>>) -> zbus::Result<()>; 47 | 48 | /// ConfigMethods property 49 | #[zbus(property)] 50 | fn config_methods(&self) -> zbus::Result; 51 | #[zbus(property)] 52 | fn set_config_methods(&self, value: &str) -> zbus::Result<()>; 53 | 54 | /// ProcessCredentials property 55 | #[zbus(property)] 56 | fn process_credentials(&self) -> zbus::Result; 57 | #[zbus(property)] 58 | fn set_process_credentials(&self, value: bool) -> zbus::Result<()>; 59 | } 60 | -------------------------------------------------------------------------------- /rs-matter-macros/src/idl/parser/endpoint_composition.rs: -------------------------------------------------------------------------------- 1 | /// Represents a specific device type 2 | /// 3 | /// API generally just reports standarde `code` values and their 4 | /// `version`. `name` is a human-friendly readable value. 5 | #[derive(Debug, Clone, PartialEq, PartialOrd, Default)] 6 | pub struct DeviceType { 7 | pub name: String, 8 | pub code: u64, 9 | pub version: u64, 10 | } 11 | 12 | /// Contains an initialization value of an attribute. 13 | #[derive(Debug, Clone, PartialEq, PartialOrd)] 14 | pub enum DefaultAttributeValue { 15 | Number(u64), 16 | Signed(i64), 17 | String(String), 18 | Bool(bool), 19 | } 20 | 21 | /// How an attribute value is fetched from the server 22 | #[derive(Debug, Clone, PartialEq, PartialOrd, Default)] 23 | pub enum AttributeHandlingType { 24 | /// Stored in RAM, may be lost at reboot 25 | #[default] 26 | Ram, 27 | /// Cluster provides custom code to handle read/writes 28 | Callback, 29 | /// Stored in RAM and persisted in NVM 30 | Persist, 31 | } 32 | 33 | /// Describes an attribute made available on a server 34 | /// 35 | /// Name should be looked up in the corresponding cluster definition 36 | /// to figure out actual type/sizing and other information. 37 | #[derive(Debug, Clone, PartialEq, PartialOrd, Default)] 38 | pub struct AttributeInstantiation { 39 | pub handle_type: AttributeHandlingType, 40 | pub name: String, 41 | pub default: Option, 42 | } 43 | 44 | /// A cluster instantiated on a specific endpoint 45 | /// 46 | /// Data is generally string-typed and the actual types should be 47 | /// looked up in the cluster definition if required. 48 | #[derive(Debug, Clone, PartialEq, PartialOrd, Default)] 49 | pub struct ClusterInstantiation { 50 | pub name: String, 51 | pub attributes: Vec, 52 | pub commands: Vec, 53 | pub events: Vec, 54 | } 55 | 56 | /// Represents and endpoint exposed by a server. 57 | #[derive(Debug, Clone, PartialEq, PartialOrd, Default)] 58 | pub struct Endpoint { 59 | pub id: u64, 60 | pub device_types: Vec, 61 | pub bindings: Vec, 62 | pub instantiations: Vec, 63 | } 64 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/access_point.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.AccessPoint` 19 | 20 | use zbus::proxy; 21 | 22 | #[proxy( 23 | interface = "org.freedesktop.NetworkManager.AccessPoint", 24 | default_service = "org.freedesktop.NetworkManager" 25 | )] 26 | pub trait AccessPoint { 27 | /// Flags property 28 | #[zbus(property)] 29 | fn flags(&self) -> zbus::Result; 30 | 31 | /// WpaFlags property 32 | #[zbus(property)] 33 | fn wpa_flags(&self) -> zbus::Result; 34 | 35 | /// RsnFlags property 36 | #[zbus(property)] 37 | fn rsn_flags(&self) -> zbus::Result; 38 | 39 | /// ssid property 40 | #[zbus(property)] 41 | fn ssid(&self) -> zbus::Result>; 42 | 43 | /// Frequency property 44 | #[zbus(property)] 45 | fn frequency(&self) -> zbus::Result; 46 | 47 | /// HwAddress property 48 | #[zbus(property)] 49 | fn hw_address(&self) -> zbus::Result; 50 | 51 | /// Mode property 52 | #[zbus(property)] 53 | fn mode(&self) -> zbus::Result; 54 | 55 | /// MaxBitrate property 56 | #[zbus(property)] 57 | fn max_bitrate(&self) -> zbus::Result; 58 | 59 | /// Bandwidth property 60 | #[zbus(property)] 61 | fn bandwidth(&self) -> zbus::Result; 62 | 63 | /// Strength property 64 | #[zbus(property)] 65 | fn strength(&self) -> zbus::Result; 66 | 67 | /// LastSeen property 68 | #[zbus(property)] 69 | fn last_seen(&self) -> zbus::Result; 70 | } 71 | -------------------------------------------------------------------------------- /rs-matter/src/dm/types/endpoint.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 | use core::fmt; 19 | 20 | use super::{Cluster, ClusterId, DeviceType, EndptId}; 21 | 22 | /// A type modeling the endpoint meta-data in the Matter data model. 23 | #[derive(Debug, Clone)] 24 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] 25 | pub struct Endpoint<'a> { 26 | /// The endpoint ID. 27 | pub id: EndptId, 28 | /// The list of device types associated with this endpoint. 29 | pub device_types: &'a [DeviceType], 30 | /// The list of clusters associated with this endpoint. 31 | pub clusters: &'a [Cluster<'a>], 32 | } 33 | 34 | impl<'a> Endpoint<'a> { 35 | /// Create a new `Endpoint` instance. 36 | pub const fn new( 37 | id: EndptId, 38 | device_types: &'a [DeviceType], 39 | clusters: &'a [Cluster<'a>], 40 | ) -> Self { 41 | Self { 42 | id, 43 | device_types, 44 | clusters, 45 | } 46 | } 47 | 48 | /// Return a reference to the cluster with the given ID, if it exists. 49 | pub fn cluster(&self, id: ClusterId) -> Option<&Cluster<'a>> { 50 | self.clusters.iter().find(|cluster| cluster.id == id) 51 | } 52 | } 53 | 54 | impl core::fmt::Display for Endpoint<'_> { 55 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 56 | write!(f, "clusters:[")?; 57 | let mut comma = ""; 58 | for cluster in self.clusters { 59 | write!(f, "{} {{ {} }}", comma, cluster)?; 60 | comma = ", "; 61 | } 62 | 63 | write!(f, "]") 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /scripts/memory/memdf/collector/bloaty.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021 Project CHIP Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | """Collect memory information from bloaty.""" 17 | 18 | import io 19 | import os 20 | 21 | import memdf.util.subprocess 22 | import pandas as pd # type: ignore 23 | from memdf import Config, ConfigDescription, DFs, SymbolDF 24 | from memdf.collector.util import simplify_source 25 | 26 | CONFIG: ConfigDescription = { 27 | 'tool.bloaty': { 28 | 'help': 'File name of the bloaty executable', 29 | 'metavar': 'FILE', 30 | 'default': 'bloaty', 31 | }, 32 | } 33 | 34 | 35 | def read_symbols(config: Config, filename: str) -> SymbolDF: 36 | """Read a binary's symbol map using bloaty.""" 37 | column_map = { 38 | 'compileunits': 'cu', 39 | 'sections': 'section', 40 | 'symbols': 'symbol', 41 | 'vmsize': 'size', 42 | } 43 | process = memdf.util.subprocess.run_tool_pipe(config, [ 44 | 'bloaty', '--tsv', '--demangle=none', '-n', '0', '-d', 45 | 'compileunits,sections,symbols', filename 46 | ]) 47 | if not process or not process.stdout: 48 | return SymbolDF() 49 | df = pd.read_table(io.TextIOWrapper(process.stdout, newline=os.linesep), 50 | usecols=list(column_map.keys()), 51 | dtype=SymbolDF.dtype, 52 | na_filter=False) 53 | df.rename(inplace=True, columns=column_map) 54 | prefixes = config.get_re('collect.prefix') 55 | df['cu'] = df['cu'].apply(lambda s: simplify_source(s, prefixes)) 56 | return df 57 | 58 | 59 | def read_file(config: Config, filename: str, method: str = None) -> DFs: 60 | """Read a binary's memory map using bloaty.""" 61 | return {SymbolDF.name: read_symbols(config, filename)} 62 | -------------------------------------------------------------------------------- /rs-matter/src/group_keys.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 | use crate::{ 19 | crypto::{self, SYMM_KEY_LEN_BYTES}, 20 | error::{Error, ErrorCode}, 21 | tlv::{FromTLV, ToTLV}, 22 | utils::init::{init, zeroed, Init}, 23 | }; 24 | 25 | type KeySetKey = [u8; SYMM_KEY_LEN_BYTES]; 26 | 27 | #[derive(Debug, Default, FromTLV, ToTLV)] 28 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] 29 | pub struct KeySet { 30 | pub epoch_key: KeySetKey, 31 | pub op_key: KeySetKey, 32 | } 33 | 34 | impl KeySet { 35 | pub const fn new0() -> Self { 36 | Self { 37 | epoch_key: [0; SYMM_KEY_LEN_BYTES], 38 | op_key: [0; SYMM_KEY_LEN_BYTES], 39 | } 40 | } 41 | 42 | pub fn init() -> impl Init { 43 | init!(Self { 44 | epoch_key <- zeroed(), 45 | op_key <- zeroed(), 46 | }) 47 | } 48 | 49 | pub fn new(epoch_key: &[u8], compressed_id: &[u8]) -> Result { 50 | let mut ks = KeySet::default(); 51 | KeySet::op_key_from_ipk(epoch_key, compressed_id, &mut ks.op_key)?; 52 | ks.epoch_key.copy_from_slice(epoch_key); 53 | Ok(ks) 54 | } 55 | 56 | fn op_key_from_ipk(ipk: &[u8], compressed_id: &[u8], opkey: &mut [u8]) -> Result<(), Error> { 57 | const GRP_KEY_INFO: [u8; 13] = [ 58 | 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4b, 0x65, 0x79, 0x20, 0x76, 0x31, 0x2e, 0x30, 59 | ]; 60 | 61 | crypto::hkdf_sha256(compressed_id, ipk, &GRP_KEY_INFO, opkey) 62 | .map_err(|_| ErrorCode::InvalidData.into()) 63 | } 64 | 65 | pub fn op_key(&self) -> &[u8] { 66 | &self.op_key 67 | } 68 | 69 | pub fn epoch_key(&self) -> &[u8] { 70 | &self.epoch_key 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /rs-matter/src/sc/crypto/dummy.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 | use crate::{ 19 | error::{Error, ErrorCode}, 20 | utils::rand::Rand, 21 | }; 22 | 23 | #[allow(non_snake_case)] 24 | pub struct CryptoSpake2 {} 25 | 26 | impl CryptoSpake2 { 27 | #[allow(non_snake_case)] 28 | pub fn new() -> Result { 29 | Ok(Self {}) 30 | } 31 | 32 | // Computes w0 from w0s respectively 33 | pub fn set_w0_from_w0s(&mut self, _w0s: &[u8]) -> Result<(), Error> { 34 | Err(ErrorCode::Invalid.into()) 35 | } 36 | 37 | pub fn set_w1_from_w1s(&mut self, _w1s: &[u8]) -> Result<(), Error> { 38 | Err(ErrorCode::Invalid.into()) 39 | } 40 | 41 | pub fn set_w0(&mut self, _w0: &[u8]) -> Result<(), Error> { 42 | Err(ErrorCode::Invalid.into()) 43 | } 44 | 45 | pub fn set_w1(&mut self, _w1: &[u8]) -> Result<(), Error> { 46 | Err(ErrorCode::Invalid.into()) 47 | } 48 | 49 | #[allow(non_snake_case)] 50 | pub fn set_L(&mut self, _l: &[u8]) -> Result<(), Error> { 51 | Err(ErrorCode::Invalid.into()) 52 | } 53 | 54 | #[allow(non_snake_case)] 55 | #[allow(dead_code)] 56 | pub fn set_L_from_w1s(&mut self, _w1s: &[u8]) -> Result<(), Error> { 57 | Err(ErrorCode::Invalid.into()) 58 | } 59 | 60 | #[allow(non_snake_case)] 61 | pub fn get_pB(&mut self, _pB: &mut [u8], _rand: Rand) -> Result<(), Error> { 62 | Err(ErrorCode::Invalid.into()) 63 | } 64 | 65 | #[allow(non_snake_case)] 66 | pub fn get_TT_as_verifier( 67 | &mut self, 68 | _context: &[u8], 69 | _pA: &[u8], 70 | _pB: &[u8], 71 | _out: &mut [u8], 72 | ) -> Result<(), Error> { 73 | Err(ErrorCode::Invalid.into()) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/ip6config.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.IP6Config` 19 | 20 | #![allow(clippy::type_complexity)] 21 | 22 | use std::collections::HashMap; 23 | 24 | use zbus::proxy; 25 | use zbus::zvariant::OwnedValue; 26 | 27 | #[proxy( 28 | interface = "org.freedesktop.NetworkManager.IP6Config", 29 | default_service = "org.freedesktop.NetworkManager" 30 | )] 31 | pub trait IP6Config { 32 | /// AddressData property 33 | #[zbus(property)] 34 | fn address_data(&self) -> zbus::Result>>; 35 | 36 | /// Addresses property 37 | #[zbus(property)] 38 | fn addresses(&self) -> zbus::Result, u32, Vec)>>; 39 | 40 | /// DnsOptions property 41 | #[zbus(property)] 42 | fn dns_options(&self) -> zbus::Result>; 43 | 44 | /// DnsPriority property 45 | #[zbus(property)] 46 | fn dns_priority(&self) -> zbus::Result; 47 | 48 | /// Domains property 49 | #[zbus(property)] 50 | fn domains(&self) -> zbus::Result>; 51 | 52 | /// Gateway property 53 | #[zbus(property)] 54 | fn gateway(&self) -> zbus::Result; 55 | 56 | /// Nameservers property 57 | #[zbus(property)] 58 | fn nameservers(&self) -> zbus::Result>>; 59 | 60 | /// RouteData property 61 | #[zbus(property)] 62 | fn route_data(&self) -> zbus::Result>>; 63 | 64 | /// Routes property 65 | #[zbus(property)] 66 | fn routes(&self) -> zbus::Result, u32, Vec, u32)>>; 67 | 68 | /// Searches property 69 | #[zbus(property)] 70 | fn searches(&self) -> zbus::Result>; 71 | } 72 | -------------------------------------------------------------------------------- /rs-matter/src/im/status.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 | //! This module defines the `Status` and `StatusResp` structures used in the Interaction Model. 19 | 20 | use crate::error::Error; 21 | use crate::tlv::{FromTLV, TagType, ToTLV}; 22 | use crate::utils::storage::WriteBuf; 23 | 24 | use super::IMStatusCode; 25 | 26 | /// An IM status structure that contains an `IMStatusCode` and an optional cluster status code. 27 | /// 28 | /// Corresponds to the `StatusIB` block in the Matter Interaction Model. 29 | #[derive(Debug, Clone, PartialEq, Eq, Hash, FromTLV, ToTLV)] 30 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] 31 | pub struct Status { 32 | /// The status code of the IM operation. 33 | pub status: IMStatusCode, 34 | /// An optional cluster status code, which is used for cluster-specific status codes. 35 | pub cluster_status: Option, 36 | } 37 | 38 | impl Status { 39 | /// Create a new `Status` instance with the given `IMStatusCode` and an optional cluster status code. 40 | pub const fn new(status: IMStatusCode, cluster_status: Option) -> Status { 41 | Status { 42 | status, 43 | cluster_status, 44 | } 45 | } 46 | } 47 | 48 | /// An IM status response structure used for sending/receiving status responses in the Interaction Model. 49 | /// 50 | /// Corresponds to the `StatusResponseMessage` struct in the Matter Interaction Model. 51 | #[derive(Debug, Clone, PartialEq, Eq, Hash, FromTLV, ToTLV)] 52 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] 53 | pub struct StatusResp { 54 | pub status: IMStatusCode, 55 | } 56 | 57 | impl StatusResp { 58 | pub fn write(wb: &mut WriteBuf, status: IMStatusCode) -> Result<(), Error> { 59 | let status = Self { status }; 60 | status.to_tlv(&TagType::Anonymous, wb) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/macsec.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.Macsec` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.Macsec", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait Macsec { 28 | /// Parent property 29 | #[zbus(property)] 30 | fn parent(&self) -> zbus::Result; 31 | 32 | /// Sci property 33 | #[zbus(property)] 34 | fn sci(&self) -> zbus::Result; 35 | 36 | /// IcvLength property 37 | #[zbus(property)] 38 | fn icv_length(&self) -> zbus::Result; 39 | 40 | /// CipherSuite property 41 | #[zbus(property)] 42 | fn cipher_suite(&self) -> zbus::Result; 43 | 44 | /// Window property 45 | #[zbus(property)] 46 | fn window(&self) -> zbus::Result; 47 | 48 | /// EncodingSa property 49 | #[zbus(property)] 50 | fn encoding_sa(&self) -> zbus::Result; 51 | 52 | /// Validation property 53 | #[zbus(property)] 54 | fn validation(&self) -> zbus::Result; 55 | 56 | /// Encrypt property 57 | #[zbus(property)] 58 | fn encrypt(&self) -> zbus::Result; 59 | 60 | /// Protect property 61 | #[zbus(property)] 62 | fn protect(&self) -> zbus::Result; 63 | 64 | /// IncludeSci property 65 | #[zbus(property)] 66 | fn include_sci(&self) -> zbus::Result; 67 | 68 | /// Es property 69 | #[zbus(property)] 70 | fn es(&self) -> zbus::Result; 71 | 72 | /// Scb property 73 | #[zbus(property)] 74 | fn scb(&self) -> zbus::Result; 75 | 76 | /// ReplayProtect property 77 | #[zbus(property)] 78 | fn replay_protect(&self) -> zbus::Result; 79 | } 80 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/device/ip_tunnel.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.Device.IPTunnel` 19 | 20 | use zbus::proxy; 21 | use zbus::zvariant::OwnedObjectPath; 22 | 23 | #[proxy( 24 | interface = "org.freedesktop.NetworkManager.Device.IPTunnel", 25 | default_service = "org.freedesktop.NetworkManager" 26 | )] 27 | pub trait IPTunnel { 28 | /// Mode property 29 | #[zbus(property)] 30 | fn mode(&self) -> zbus::Result; 31 | 32 | /// Parent property 33 | #[zbus(property)] 34 | fn parent(&self) -> zbus::Result; 35 | 36 | /// Local property 37 | #[zbus(property)] 38 | fn local(&self) -> zbus::Result; 39 | 40 | /// Remote property 41 | #[zbus(property)] 42 | fn remote(&self) -> zbus::Result; 43 | 44 | /// Ttl property 45 | #[zbus(property)] 46 | fn ttl(&self) -> zbus::Result; 47 | 48 | /// Tos property 49 | #[zbus(property)] 50 | fn tos(&self) -> zbus::Result; 51 | 52 | /// PathMtuDiscovery property 53 | #[zbus(property)] 54 | fn path_mtu_discovery(&self) -> zbus::Result; 55 | 56 | /// InputKey property 57 | #[zbus(property)] 58 | fn input_key(&self) -> zbus::Result; 59 | 60 | /// OutputKey property 61 | #[zbus(property)] 62 | fn output_key(&self) -> zbus::Result; 63 | 64 | /// EncapsulationLimit property 65 | #[zbus(property)] 66 | fn encapsulation_limit(&self) -> zbus::Result; 67 | 68 | /// FlowLabel property 69 | #[zbus(property)] 70 | fn flow_label(&self) -> zbus::Result; 71 | 72 | /// FwMark property 73 | #[zbus(property)] 74 | fn fw_mark(&self) -> zbus::Result; 75 | 76 | /// Flags property 77 | #[zbus(property)] 78 | fn flags(&self) -> zbus::Result; 79 | } 80 | -------------------------------------------------------------------------------- /rs-matter/src/dm/devices.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 | use super::types::DeviceType; 19 | 20 | pub mod test; 21 | 22 | /// A constant representing the device type for the root (ep0) endpoint in Matter. 23 | pub const DEV_TYPE_ROOT_NODE: DeviceType = DeviceType { 24 | dtype: 0x0016, 25 | drev: 1, 26 | }; 27 | 28 | /// A constant representing the device type for a bridged device endpoint in the node. 29 | pub const DEV_TYPE_BRIDGED_NODE: DeviceType = DeviceType { 30 | dtype: 0x0013, 31 | drev: 1, 32 | }; 33 | 34 | /// A constant representing the device type for an aggregator endpoint in the node 35 | /// when the Node contains bridged endpoints. 36 | pub const DEV_TYPE_AGGREGATOR: DeviceType = DeviceType { 37 | dtype: 0x000e, 38 | drev: 1, 39 | }; 40 | 41 | /// A constant representing the On/Off Light device in Matter. 42 | pub const DEV_TYPE_ON_OFF_LIGHT: DeviceType = DeviceType { 43 | dtype: 0x0100, 44 | drev: 2, 45 | }; 46 | 47 | pub const DEV_TYPE_DIMMABLE_LIGHT: DeviceType = DeviceType { 48 | dtype: 0x0101, 49 | drev: 3, 50 | }; 51 | 52 | /// A constant representing the Smart Speaker device in Matter. 53 | pub const DEV_TYPE_SMART_SPEAKER: DeviceType = DeviceType { 54 | dtype: 0x0022, 55 | drev: 2, 56 | }; 57 | 58 | /// A constant representing the casting video player device in Matter. 59 | pub const DEV_TYPE_CASTING_VIDEO_PLAYER: DeviceType = DeviceType { 60 | dtype: 0x0023, 61 | drev: 1, 62 | }; 63 | 64 | /// A constant representing the video player device in Matter. 65 | pub const DEV_TYPE_VIDEO_PLAYER: DeviceType = DeviceType { 66 | dtype: 0x0028, 67 | drev: 1, 68 | }; 69 | 70 | /// A macro to generate the devices for an endpoint. 71 | #[allow(unused_macros)] 72 | #[macro_export] 73 | macro_rules! devices { 74 | ($($device:expr $(,)?)*) => { 75 | &[ 76 | $($device,)* 77 | ] 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /scripts/memory/memdf/collector/su.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021 Project CHIP Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | """Collect memory information from gcc .su files.""" 17 | 18 | import os 19 | import os.path 20 | import re 21 | from typing import IO 22 | 23 | import pandas as pd # type: ignore 24 | from memdf.df import DFs, StackDF 25 | from memdf.util.config import Config, ConfigDescription 26 | 27 | CONFIG: ConfigDescription = {} 28 | 29 | 30 | def read_su(config: Config, infile: IO) -> StackDF: 31 | columns = ['symbol', 'type', 'size', 'file', 'line'] 32 | rows = [] 33 | decoder = re.compile( 34 | r"""^(?P.+) 35 | :(?P\d+) 36 | :(?P\d+) 37 | :(?P.+) 38 | [\t](?P\d+) 39 | [\t](?P\w+) 40 | """, re.VERBOSE) 41 | for line in infile: 42 | if match := decoder.match(line.strip()): 43 | rows.append([ 44 | match.group('symbol'), 45 | match.group('type'), 46 | int(match.group('size')), 47 | match.group('file'), 48 | int(match.group('line')), 49 | ]) 50 | return StackDF(rows, columns=columns) 51 | 52 | 53 | def read_file(config: Config, filename: str, method: str = None) -> DFs: 54 | """Read a single `.su` file.""" 55 | with open(filename, 'r') as fp: 56 | return {StackDF.name: read_su(config, fp)} 57 | 58 | 59 | def read_dir(config: Config, dirname: str, method: str = None) -> DFs: 60 | """Walk a directory reading all `.su` files.""" 61 | frames = [] 62 | su_re = re.compile(r".+\.su") 63 | for path, dirnames, filenames in os.walk(dirname): 64 | for filename in filenames: 65 | if su_re.fullmatch(filename): 66 | with open(os.path.join(path, filename), 'r') as fp: 67 | frames.append(read_su(config, fp)) 68 | if frames: 69 | df = StackDF(pd.concat(frames, ignore_index=True)) 70 | else: 71 | df = StackDF() 72 | return {StackDF.name: df} 73 | -------------------------------------------------------------------------------- /rs-matter/src/pairing.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 | //! This module contains the logic for generating the pairing code and the QR code for easy pairing. 19 | 20 | use qr::no_optional_data; 21 | 22 | use crate::dm::clusters::basic_info::BasicInfoConfig; 23 | use crate::error::Error; 24 | use crate::utils::bitflags::bitflags; 25 | use crate::BasicCommData; 26 | 27 | use self::code::{compute_pairing_code, pretty_print_pairing_code}; 28 | use self::qr::{compute_qr_code_text, print_qr_code}; 29 | 30 | pub mod code; 31 | pub mod qr; 32 | 33 | bitflags! { 34 | #[repr(transparent)] 35 | #[cfg_attr(not(feature = "defmt"), derive(Debug, Copy, Clone, Eq, PartialEq, Hash))] 36 | pub struct DiscoveryCapabilities: u8 { 37 | const SOFT_AP = 0x01; 38 | const BLE = 0x02; 39 | const IP = 0x04; 40 | } 41 | } 42 | 43 | impl Default for DiscoveryCapabilities { 44 | fn default() -> Self { 45 | Self::IP 46 | } 47 | } 48 | 49 | /// Prepares and prints the pairing code and the QR code for easy pairing. 50 | pub fn print_pairing_code_and_qr( 51 | dev_det: &BasicInfoConfig, 52 | comm_data: &BasicCommData, 53 | discovery_capabilities: DiscoveryCapabilities, 54 | buf: &mut [u8], 55 | ) -> Result<(), Error> { 56 | let pairing_code = compute_pairing_code(comm_data); 57 | 58 | pretty_print_pairing_code(&pairing_code); 59 | 60 | let (qr_code, remaining_buf) = compute_qr_code_text( 61 | dev_det, 62 | comm_data, 63 | discovery_capabilities, 64 | no_optional_data, 65 | buf, 66 | )?; 67 | 68 | print_qr_code(qr_code, remaining_buf)?; 69 | 70 | Ok(()) 71 | } 72 | 73 | #[repr(u16)] 74 | pub enum VendorId { 75 | CommonOrUnspecified = 0x0000, 76 | TestVendor4 = 0xFFF4, 77 | } 78 | 79 | pub fn is_vendor_id_valid_operationally(vendor_id: u16) -> bool { 80 | (vendor_id != VendorId::CommonOrUnspecified as u16) 81 | && (vendor_id <= VendorId::TestVendor4 as u16) 82 | } 83 | -------------------------------------------------------------------------------- /scripts/memory/memdf/util/nd.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021 Project CHIP Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | """Nested dictionary utilities.""" 17 | 18 | from typing import Any, Mapping, MutableMapping, Optional, Sequence 19 | 20 | Key = Sequence 21 | 22 | 23 | def get(nd: Optional[Mapping], keys: Key, default: Any = None) -> Any: 24 | """Get a value from a nested dictionary.""" 25 | d: Any = nd 26 | while d and keys: 27 | d = d.get(keys[0]) 28 | keys = keys[1:] 29 | if d is not None and d != {}: 30 | return d 31 | if default is not None: 32 | return default 33 | return d 34 | 35 | 36 | def put(nd: MutableMapping, keys: Key, value: Any) -> None: 37 | """Store a value in a nested dictionary.""" 38 | while True: 39 | key = keys[0] 40 | keys = keys[1:] 41 | if not keys: 42 | break 43 | if key not in nd: 44 | nd[key] = {} 45 | nd = nd[key] 46 | nd[key] = value 47 | 48 | 49 | def store(nd: MutableMapping, keys: Key, value: Any, empty: Any, add) -> None: 50 | """Store a value in a nested dictionary where the leaves are containers.""" 51 | while True: 52 | key = keys[0] 53 | keys = keys[1:] 54 | if not keys: 55 | break 56 | if key not in nd: 57 | nd[key] = {} 58 | nd = nd[key] 59 | if key not in nd: 60 | nd[key] = empty 61 | add(nd[key], value) 62 | 63 | 64 | def update(nd: MutableMapping, src: Mapping) -> None: 65 | """Update a nested dictionary.""" 66 | for k, v in src.items(): 67 | if k not in nd or nd[k] is None: 68 | nd[k] = v 69 | elif isinstance(nd[k], dict) and isinstance(v, dict): 70 | update(nd[k], v) 71 | elif isinstance(nd[k], list): 72 | if isinstance(v, list): 73 | nd[k] += v 74 | else: 75 | nd[k].append(v) 76 | elif type(nd[k]) is type(v): 77 | nd[k] = v 78 | else: 79 | raise TypeError(f"type mismatch {k},{v} was {nd[k]}") 80 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/wpa_supp/bss.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 | //! # D-Bus interface proxy for: `fi.w1.wpa_supplicant1.Interface.BSS` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::proxy; 23 | use zbus::zvariant::{OwnedValue, Value}; 24 | 25 | #[proxy( 26 | interface = "fi.w1.wpa_supplicant1.BSS", 27 | default_service = "fi.w1.wpa_supplicant1" 28 | )] 29 | pub trait BSS { 30 | /// PropertiesChanged signal 31 | #[zbus(signal)] 32 | fn properties_changed(&self, properties: HashMap<&str, Value<'_>>) -> zbus::Result<()>; 33 | 34 | /// BSSID property 35 | #[zbus(property, name = "BSSID")] 36 | fn bssid(&self) -> zbus::Result>; 37 | 38 | /// SSID property 39 | #[zbus(property, name = "SSID")] 40 | fn ssid(&self) -> zbus::Result>; 41 | 42 | /// WPA property 43 | #[zbus(property, name = "WPA")] 44 | fn wpa(&self) -> zbus::Result>; 45 | 46 | /// RSN property 47 | #[zbus(property, name = "RSN")] 48 | fn rsn(&self) -> zbus::Result>; 49 | 50 | /// WPS property 51 | #[zbus(property, name = "WPS")] 52 | fn wps(&self) -> zbus::Result>; 53 | 54 | /// IEs property 55 | #[zbus(property, name = "IEs")] 56 | fn ies(&self) -> zbus::Result>; 57 | 58 | /// Privacy property 59 | #[zbus(property)] 60 | fn privacy(&self) -> zbus::Result; 61 | 62 | /// Mode property 63 | #[zbus(property)] 64 | fn mode(&self) -> zbus::Result; 65 | 66 | /// Frequency property 67 | #[zbus(property)] 68 | fn frequency(&self) -> zbus::Result; 69 | 70 | /// Rates property 71 | #[zbus(property)] 72 | fn rates(&self) -> zbus::Result>; 73 | 74 | /// Signal property 75 | #[zbus(property)] 76 | fn signal(&self) -> zbus::Result; 77 | 78 | /// Age property 79 | #[zbus(property)] 80 | fn age(&self) -> zbus::Result; 81 | } 82 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/bluez/gatt_characteristic.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 | //! # D-Bus interface proxy for: `org.bluez.GattCharacteristic1` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::{ 23 | proxy, 24 | zvariant::{OwnedFd, OwnedObjectPath, Value}, 25 | }; 26 | 27 | #[proxy(interface = "org.bluez.GattCharacteristic1", assume_defaults = true)] 28 | pub trait GattCharacteristic { 29 | /// AcquireNotify method 30 | fn acquire_notify(&self, options: HashMap<&str, &Value<'_>>) -> zbus::Result<(OwnedFd, u16)>; 31 | 32 | /// AcquireWrite method 33 | fn acquire_write(&self, options: HashMap<&str, &Value<'_>>) -> zbus::Result<(OwnedFd, u16)>; 34 | 35 | /// ReadValue method 36 | fn read_value(&self, options: HashMap<&str, &Value<'_>>) -> zbus::Result>; 37 | 38 | /// StartNotify method 39 | fn start_notify(&self) -> zbus::Result<()>; 40 | 41 | /// StopNotify method 42 | fn stop_notify(&self) -> zbus::Result<()>; 43 | 44 | /// WriteValue method 45 | fn write_value(&self, value: &[u8], options: HashMap<&str, &Value<'_>>) -> zbus::Result<()>; 46 | 47 | /// Flags property 48 | #[zbus(property)] 49 | fn flags(&self) -> zbus::Result>; 50 | 51 | /// MTU property 52 | #[zbus(property, name = "MTU")] 53 | fn mtu(&self) -> zbus::Result; 54 | 55 | /// NotifyAcquired property 56 | #[zbus(property)] 57 | fn notify_acquired(&self) -> zbus::Result; 58 | 59 | /// Notifying property 60 | #[zbus(property)] 61 | fn notifying(&self) -> zbus::Result; 62 | 63 | /// Service property 64 | #[zbus(property)] 65 | fn service(&self) -> zbus::Result; 66 | 67 | /// UUID property 68 | #[zbus(property, name = "UUID")] 69 | fn uuid(&self) -> zbus::Result; 70 | 71 | /// Value property 72 | #[zbus(property)] 73 | fn value(&self) -> zbus::Result>; 74 | 75 | /// WriteAcquired property 76 | #[zbus(property)] 77 | fn write_acquired(&self) -> zbus::Result; 78 | } 79 | -------------------------------------------------------------------------------- /rs-matter/src/utils/zbus_proxies/nm/ip4config.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 | //! # D-Bus interface proxy for: `org.freedesktop.NetworkManager.IP4Config` 19 | 20 | use std::collections::HashMap; 21 | 22 | use zbus::proxy; 23 | use zbus::zvariant::OwnedValue; 24 | 25 | #[proxy( 26 | interface = "org.freedesktop.NetworkManager.IP4Config", 27 | default_service = "org.freedesktop.NetworkManager" 28 | )] 29 | pub trait IP4Config { 30 | /// AddressData property 31 | #[zbus(property)] 32 | fn address_data(&self) -> zbus::Result>>; 33 | 34 | /// Addresses property 35 | #[zbus(property)] 36 | fn addresses(&self) -> zbus::Result>>; 37 | 38 | /// DnsOptions property 39 | #[zbus(property)] 40 | fn dns_options(&self) -> zbus::Result>; 41 | 42 | /// DnsPriority property 43 | #[zbus(property)] 44 | fn dns_priority(&self) -> zbus::Result; 45 | 46 | /// Domains property 47 | #[zbus(property)] 48 | fn domains(&self) -> zbus::Result>; 49 | 50 | /// Gateway property 51 | #[zbus(property)] 52 | fn gateway(&self) -> zbus::Result; 53 | 54 | /// NameserverData property 55 | #[zbus(property)] 56 | fn nameserver_data(&self) -> zbus::Result>>; 57 | 58 | /// Nameservers property 59 | #[zbus(property)] 60 | fn nameservers(&self) -> zbus::Result>; 61 | 62 | /// RouteData property 63 | #[zbus(property)] 64 | fn route_data(&self) -> zbus::Result>>; 65 | 66 | /// Routes property 67 | #[zbus(property)] 68 | fn routes(&self) -> zbus::Result>>; 69 | 70 | /// Searches property 71 | #[zbus(property)] 72 | fn searches(&self) -> zbus::Result>; 73 | 74 | /// WinsServerData property 75 | #[zbus(property)] 76 | fn wins_server_data(&self) -> zbus::Result>; 77 | 78 | /// WinsServers property 79 | #[zbus(property)] 80 | fn wins_servers(&self) -> zbus::Result>; 81 | } 82 | --------------------------------------------------------------------------------