#![allow(
clippy::all,
clippy::pedantic,
dead_code,
unreachable_pub,
unused_imports
)]
use crate::datatypes::SemanticTagStruct;
use crate::error::ClusterError;
use crate::types::Nullable;
use matter_codec::{ContainerKind, Element, Tag, TlvReader, TlvWriter, Value};
pub const CLUSTER_ID: u32 = 0x003B;
pub const CLUSTER_REVISION: u16 = 2;
pub mod command_id {}
pub mod attribute_id {
pub const NUMBER_OF_POSITIONS: u32 = 0x0000;
pub const CURRENT_POSITION: u32 = 0x0001;
pub const MULTI_PRESS_MAX: u32 = 0x0002;
}
bitflags::bitflags! {
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Feature: u32 {
const LS = 1 << 0;
const MS = 1 << 1;
const MSR = 1 << 2;
const MSL = 1 << 3;
const MSM = 1 << 4;
const AS = 1 << 5;
}
}
pub fn decode_number_of_positions(tlv: &[u8]) -> Result<u8, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u8::try_from(v).map_err(|_| ClusterError::InvalidLength("NumberOfPositions"))?),
_ => Err(ClusterError::UnexpectedType {
context: "NumberOfPositions",
}),
}
}
pub fn decode_current_position(tlv: &[u8]) -> Result<u8, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u8::try_from(v).map_err(|_| ClusterError::InvalidLength("CurrentPosition"))?),
_ => Err(ClusterError::UnexpectedType {
context: "CurrentPosition",
}),
}
}
pub fn decode_multi_press_max(tlv: &[u8]) -> Result<u8, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u8::try_from(v).map_err(|_| ClusterError::InvalidLength("MultiPressMax"))?),
_ => Err(ClusterError::UnexpectedType {
context: "MultiPressMax",
}),
}
}