matc 0.1.3

Matter protocol library (controller side)
Documentation
//! Matter TLV encoders and decoders for Refrigerator Alarm Cluster
//! Cluster ID: 0x0057
//!
//! This file is automatically generated from RefrigeratorAlarm.xml

#![allow(clippy::too_many_arguments)]

use anyhow;
use serde_json;


// Bitmap definitions

/// Alarm bitmap type
pub type Alarm = u8;

/// Constants for Alarm
pub mod alarm {
    /// The cabinet's door has been open for a vendor defined amount of time.
    pub const DOOR_OPEN: u8 = 0x01;
}

// Command encoders

// Command listing

pub fn get_command_list() -> Vec<(u32, &'static str)> {
    vec![
        (0x01, "ModifyEnabledAlarms"),
    ]
}

pub fn get_command_name(cmd_id: u32) -> Option<&'static str> {
    match cmd_id {
        0x01 => Some("ModifyEnabledAlarms"),
        _ => None,
    }
}

pub fn get_command_schema(cmd_id: u32) -> Option<Vec<crate::clusters::codec::CommandField>> {
    match cmd_id {
        0x01 => Some(vec![]),
        _ => None,
    }
}

pub fn encode_command_json(cmd_id: u32, _args: &serde_json::Value) -> anyhow::Result<Vec<u8>> {
    match cmd_id {
        0x01 => Ok(vec![]),
        _ => Err(anyhow::anyhow!("unknown command ID: 0x{:02X}", cmd_id)),
    }
}

// Typed facade (invokes + reads)

/// Invoke `ModifyEnabledAlarms` command on cluster `Refrigerator Alarm`.
pub async fn modify_enabled_alarms(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
    conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_REFRIGERATOR_ALARM, crate::clusters::defs::CLUSTER_REFRIGERATOR_ALARM_CMD_ID_MODIFYENABLEDALARMS, &[]).await?;
    Ok(())
}