matc/clusters/codec/
low_power.rs

1//! Matter TLV encoders and decoders for Low Power Cluster
2//! Cluster ID: 0x0508
3//!
4//! This file is automatically generated from LowPower.xml
5
6#![allow(clippy::too_many_arguments)]
7
8use anyhow;
9use serde_json;
10
11
12// Command encoders
13
14// Command listing
15
16pub fn get_command_list() -> Vec<(u32, &'static str)> {
17    vec![
18        (0x00, "Sleep"),
19    ]
20}
21
22pub fn get_command_name(cmd_id: u32) -> Option<&'static str> {
23    match cmd_id {
24        0x00 => Some("Sleep"),
25        _ => None,
26    }
27}
28
29pub fn get_command_schema(cmd_id: u32) -> Option<Vec<crate::clusters::codec::CommandField>> {
30    match cmd_id {
31        0x00 => Some(vec![]),
32        _ => None,
33    }
34}
35
36pub fn encode_command_json(cmd_id: u32, _args: &serde_json::Value) -> anyhow::Result<Vec<u8>> {
37    match cmd_id {
38        0x00 => Ok(vec![]),
39        _ => Err(anyhow::anyhow!("unknown command ID: 0x{:02X}", cmd_id)),
40    }
41}
42
43// Typed facade (invokes + reads)
44
45/// Invoke `Sleep` command on cluster `Low Power`.
46pub async fn sleep(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
47    conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_LOW_POWER, crate::clusters::defs::CLUSTER_LOW_POWER_CMD_ID_SLEEP, &[]).await?;
48    Ok(())
49}
50