#![allow(unused_imports)]
use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
use crate::dm::meta::{EventPriority, Reporting};
use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
use crate::error::Result;
use crate::im::{AttributeId, ClusterId, CommandId, EventId};
use crate::tlv::{
ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
};
pub const ID: ClusterId = 0x0300;
pub const REVISION: u16 = 9;
pub const PICS: &str = "CC";
pub mod feature {
pub const HUE_SATURATION: u32 = 1 << 0;
pub const ENHANCED_HUE: u32 = 1 << 1;
pub const COLOR_LOOP: u32 = 1 << 2;
pub const XY: u32 = 1 << 3;
pub const COLOR_TEMPERATURE: u32 = 1 << 4;
}
pub const FEATURES: &[Feature] = &[
Feature {
bit: 0,
code: "HS",
name: "HueSaturation",
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Feature {
bit: 1,
code: "EHUE",
name: "EnhancedHue",
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Feature {
bit: 2,
code: "CL",
name: "ColorLoop",
conform: Conform::OPTIONAL,
},
Feature {
bit: 3,
code: "XY",
name: "XY",
conform: Conform::OPTIONAL,
},
Feature {
bit: 4,
code: "CT",
name: "ColorTemperature",
conform: Conform::OPTIONAL,
},
];
pub mod attribute {
use crate::im::AttributeId;
pub const CURRENT_HUE: AttributeId = 0x00;
pub const CURRENT_SATURATION: AttributeId = 0x01;
pub const REMAINING_TIME: AttributeId = 0x02;
pub const CURRENT_X: AttributeId = 0x03;
pub const CURRENT_Y: AttributeId = 0x04;
pub const DRIFT_COMPENSATION: AttributeId = 0x05;
pub const COMPENSATION_TEXT: AttributeId = 0x06;
pub const COLOR_TEMPERATURE_MIREDS: AttributeId = 0x07;
pub const COLOR_MODE: AttributeId = 0x08;
pub const OPTIONS: AttributeId = 0x0F;
pub const NUMBER_OF_PRIMARIES: AttributeId = 0x10;
pub const PRIMARY1_X: AttributeId = 0x11;
pub const PRIMARY1_Y: AttributeId = 0x12;
pub const PRIMARY1_INTENSITY: AttributeId = 0x13;
pub const PRIMARY2_X: AttributeId = 0x15;
pub const PRIMARY2_Y: AttributeId = 0x16;
pub const PRIMARY2_INTENSITY: AttributeId = 0x17;
pub const PRIMARY3_X: AttributeId = 0x19;
pub const PRIMARY3_Y: AttributeId = 0x1A;
pub const PRIMARY3_INTENSITY: AttributeId = 0x1B;
pub const PRIMARY4_X: AttributeId = 0x20;
pub const PRIMARY4_Y: AttributeId = 0x21;
pub const PRIMARY4_INTENSITY: AttributeId = 0x22;
pub const PRIMARY5_X: AttributeId = 0x24;
pub const PRIMARY5_Y: AttributeId = 0x25;
pub const PRIMARY5_INTENSITY: AttributeId = 0x26;
pub const PRIMARY6_X: AttributeId = 0x28;
pub const PRIMARY6_Y: AttributeId = 0x29;
pub const PRIMARY6_INTENSITY: AttributeId = 0x2A;
pub const WHITE_POINT_X: AttributeId = 0x30;
pub const WHITE_POINT_Y: AttributeId = 0x31;
pub const COLOR_POINT_RX: AttributeId = 0x32;
pub const COLOR_POINT_RY: AttributeId = 0x33;
pub const COLOR_POINT_R_INTENSITY: AttributeId = 0x34;
pub const COLOR_POINT_GX: AttributeId = 0x36;
pub const COLOR_POINT_GY: AttributeId = 0x37;
pub const COLOR_POINT_G_INTENSITY: AttributeId = 0x38;
pub const COLOR_POINT_BX: AttributeId = 0x3A;
pub const COLOR_POINT_BY: AttributeId = 0x3B;
pub const COLOR_POINT_B_INTENSITY: AttributeId = 0x3C;
pub const ENHANCED_CURRENT_HUE: AttributeId = 0x4000;
pub const ENHANCED_COLOR_MODE: AttributeId = 0x4001;
pub const COLOR_LOOP_ACTIVE: AttributeId = 0x4002;
pub const COLOR_LOOP_DIRECTION: AttributeId = 0x4003;
pub const COLOR_LOOP_TIME: AttributeId = 0x4004;
pub const COLOR_LOOP_START_ENHANCED_HUE: AttributeId = 0x4005;
pub const COLOR_LOOP_STORED_ENHANCED_HUE: AttributeId = 0x4006;
pub const COLOR_CAPABILITIES: AttributeId = 0x400A;
pub const COLOR_TEMP_PHYSICAL_MIN_MIREDS: AttributeId = 0x400B;
pub const COLOR_TEMP_PHYSICAL_MAX_MIREDS: AttributeId = 0x400C;
pub const COUPLE_COLOR_TEMP_TO_LEVEL_MIN_MIREDS: AttributeId = 0x400D;
pub const START_UP_COLOR_TEMPERATURE_MIREDS: AttributeId = 0x4010;
}
pub mod command {
use crate::im::CommandId;
pub const MOVE_TO_HUE: CommandId = 0x00;
pub const MOVE_HUE: CommandId = 0x01;
pub const STEP_HUE: CommandId = 0x02;
pub const MOVE_TO_SATURATION: CommandId = 0x03;
pub const MOVE_SATURATION: CommandId = 0x04;
pub const STEP_SATURATION: CommandId = 0x05;
pub const MOVE_TO_HUE_AND_SATURATION: CommandId = 0x06;
pub const MOVE_TO_COLOR: CommandId = 0x07;
pub const MOVE_COLOR: CommandId = 0x08;
pub const STEP_COLOR: CommandId = 0x09;
pub const MOVE_TO_COLOR_TEMPERATURE: CommandId = 0x0A;
pub const ENHANCED_MOVE_TO_HUE: CommandId = 0x40;
pub const ENHANCED_MOVE_HUE: CommandId = 0x41;
pub const ENHANCED_STEP_HUE: CommandId = 0x42;
pub const ENHANCED_MOVE_TO_HUE_AND_SATURATION: CommandId = 0x43;
pub const COLOR_LOOP_SET: CommandId = 0x44;
pub const STOP_MOVE_STEP: CommandId = 0x47;
pub const MOVE_COLOR_TEMPERATURE: CommandId = 0x4B;
pub const STEP_COLOR_TEMPERATURE: CommandId = 0x4C;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum ColorLoopActionEnum {
Deactivate = 0,
ActivateFromColorLoopStartEnhancedHue = 1,
ActivateFromEnhancedCurrentHue = 2,
}
impl ColorLoopActionEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Deactivate),
1 => Some(Self::ActivateFromColorLoopStartEnhancedHue),
2 => Some(Self::ActivateFromEnhancedCurrentHue),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for ColorLoopActionEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for ColorLoopActionEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum ColorLoopDirectionEnum {
Decrement = 0,
Increment = 1,
}
impl ColorLoopDirectionEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Decrement),
1 => Some(Self::Increment),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for ColorLoopDirectionEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for ColorLoopDirectionEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum ColorModeEnum {
CurrentHueAndCurrentSaturation = 0,
CurrentXAndCurrentY = 1,
ColorTemperatureMireds = 2,
}
impl ColorModeEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::CurrentHueAndCurrentSaturation),
1 => Some(Self::CurrentXAndCurrentY),
2 => Some(Self::ColorTemperatureMireds),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for ColorModeEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for ColorModeEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum DirectionEnum {
Shortest = 0,
Longest = 1,
Up = 2,
Down = 3,
}
impl DirectionEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Shortest),
1 => Some(Self::Longest),
2 => Some(Self::Up),
3 => Some(Self::Down),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for DirectionEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for DirectionEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum DriftCompensationEnum {
None = 0,
OtherOrUnknown = 1,
TemperatureMonitoring = 2,
OpticalLuminanceMonitoringAndFeedback = 3,
OpticalColorMonitoringAndFeedback = 4,
}
impl DriftCompensationEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::None),
1 => Some(Self::OtherOrUnknown),
2 => Some(Self::TemperatureMonitoring),
3 => Some(Self::OpticalLuminanceMonitoringAndFeedback),
4 => Some(Self::OpticalColorMonitoringAndFeedback),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for DriftCompensationEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for DriftCompensationEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum EnhancedColorModeEnum {
CurrentHueAndCurrentSaturation = 0,
CurrentXAndCurrentY = 1,
ColorTemperatureMireds = 2,
EnhancedCurrentHueAndCurrentSaturation = 3,
}
impl EnhancedColorModeEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::CurrentHueAndCurrentSaturation),
1 => Some(Self::CurrentXAndCurrentY),
2 => Some(Self::ColorTemperatureMireds),
3 => Some(Self::EnhancedCurrentHueAndCurrentSaturation),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for EnhancedColorModeEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for EnhancedColorModeEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum MoveModeEnum {
Stop = 0,
Up = 1,
Down = 3,
}
impl MoveModeEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Stop),
1 => Some(Self::Up),
3 => Some(Self::Down),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for MoveModeEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for MoveModeEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum StepModeEnum {
Up = 1,
Down = 3,
}
impl StepModeEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
1 => Some(Self::Up),
3 => Some(Self::Down),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for StepModeEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for StepModeEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
bitflags::bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct ColorCapabilitiesBitmap: u8 {
const HUE_SATURATION = 1 << 0;
const ENHANCED_HUE = 1 << 1;
const COLOR_LOOP = 1 << 2;
const XY = 1 << 3;
const COLOR_TEMPERATURE = 1 << 4;
}
}
impl ToTlv for ColorCapabilitiesBitmap {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.bits().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for ColorCapabilitiesBitmap {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
bitflags::bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct OptionsBitmap: u8 {
const EXECUTE_IF_OFF = 1 << 0;
}
}
impl ToTlv for OptionsBitmap {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.bits().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for OptionsBitmap {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
bitflags::bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct UpdateFlagsBitmap: u8 {
const UPDATE_ACTION = 1 << 0;
const UPDATE_DIRECTION = 1 << 1;
const UPDATE_TIME = 1 << 2;
const UPDATE_START_HUE = 1 << 3;
}
}
impl ToTlv for UpdateFlagsBitmap {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.bits().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for UpdateFlagsBitmap {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MoveToHueFields {
pub hue: u8,
pub direction: DirectionEnum,
pub transition_time: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for MoveToHueFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.hue.to_tlv(w, Tag::Context(0))?;
self.direction.to_tlv(w, Tag::Context(1))?;
self.transition_time.to_tlv(w, Tag::Context(2))?;
self.options_mask.to_tlv(w, Tag::Context(3))?;
self.options_override.to_tlv(w, Tag::Context(4))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for MoveToHueFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut hue = None;
let mut direction = None;
let mut transition_time = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => hue = Some(<u8>::from_tlv(reader, &field)?),
Some(1) => direction = Some(<DirectionEnum>::from_tlv(reader, &field)?),
Some(2) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
Some(3) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(4) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
hue: hue.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
direction: direction.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MoveHueFields {
pub move_mode: MoveModeEnum,
pub rate: u8,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for MoveHueFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.move_mode.to_tlv(w, Tag::Context(0))?;
self.rate.to_tlv(w, Tag::Context(1))?;
self.options_mask.to_tlv(w, Tag::Context(2))?;
self.options_override.to_tlv(w, Tag::Context(3))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for MoveHueFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut move_mode = None;
let mut rate = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => move_mode = Some(<MoveModeEnum>::from_tlv(reader, &field)?),
Some(1) => rate = Some(<u8>::from_tlv(reader, &field)?),
Some(2) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(3) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
move_mode: move_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
rate: rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct StepHueFields {
pub step_mode: StepModeEnum,
pub step_size: u8,
pub transition_time: u8,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for StepHueFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.step_mode.to_tlv(w, Tag::Context(0))?;
self.step_size.to_tlv(w, Tag::Context(1))?;
self.transition_time.to_tlv(w, Tag::Context(2))?;
self.options_mask.to_tlv(w, Tag::Context(3))?;
self.options_override.to_tlv(w, Tag::Context(4))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for StepHueFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut step_mode = None;
let mut step_size = None;
let mut transition_time = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => step_mode = Some(<StepModeEnum>::from_tlv(reader, &field)?),
Some(1) => step_size = Some(<u8>::from_tlv(reader, &field)?),
Some(2) => transition_time = Some(<u8>::from_tlv(reader, &field)?),
Some(3) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(4) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
step_mode: step_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
step_size: step_size.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MoveToSaturationFields {
pub saturation: u8,
pub transition_time: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for MoveToSaturationFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.saturation.to_tlv(w, Tag::Context(0))?;
self.transition_time.to_tlv(w, Tag::Context(1))?;
self.options_mask.to_tlv(w, Tag::Context(2))?;
self.options_override.to_tlv(w, Tag::Context(3))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for MoveToSaturationFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut saturation = None;
let mut transition_time = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => saturation = Some(<u8>::from_tlv(reader, &field)?),
Some(1) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
Some(2) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(3) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
saturation: saturation.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MoveSaturationFields {
pub move_mode: MoveModeEnum,
pub rate: u8,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for MoveSaturationFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.move_mode.to_tlv(w, Tag::Context(0))?;
self.rate.to_tlv(w, Tag::Context(1))?;
self.options_mask.to_tlv(w, Tag::Context(2))?;
self.options_override.to_tlv(w, Tag::Context(3))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for MoveSaturationFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut move_mode = None;
let mut rate = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => move_mode = Some(<MoveModeEnum>::from_tlv(reader, &field)?),
Some(1) => rate = Some(<u8>::from_tlv(reader, &field)?),
Some(2) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(3) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
move_mode: move_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
rate: rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct StepSaturationFields {
pub step_mode: StepModeEnum,
pub step_size: u8,
pub transition_time: u8,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for StepSaturationFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.step_mode.to_tlv(w, Tag::Context(0))?;
self.step_size.to_tlv(w, Tag::Context(1))?;
self.transition_time.to_tlv(w, Tag::Context(2))?;
self.options_mask.to_tlv(w, Tag::Context(3))?;
self.options_override.to_tlv(w, Tag::Context(4))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for StepSaturationFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut step_mode = None;
let mut step_size = None;
let mut transition_time = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => step_mode = Some(<StepModeEnum>::from_tlv(reader, &field)?),
Some(1) => step_size = Some(<u8>::from_tlv(reader, &field)?),
Some(2) => transition_time = Some(<u8>::from_tlv(reader, &field)?),
Some(3) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(4) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
step_mode: step_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
step_size: step_size.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MoveToHueAndSaturationFields {
pub hue: u8,
pub saturation: u8,
pub transition_time: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for MoveToHueAndSaturationFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.hue.to_tlv(w, Tag::Context(0))?;
self.saturation.to_tlv(w, Tag::Context(1))?;
self.transition_time.to_tlv(w, Tag::Context(2))?;
self.options_mask.to_tlv(w, Tag::Context(3))?;
self.options_override.to_tlv(w, Tag::Context(4))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for MoveToHueAndSaturationFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut hue = None;
let mut saturation = None;
let mut transition_time = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => hue = Some(<u8>::from_tlv(reader, &field)?),
Some(1) => saturation = Some(<u8>::from_tlv(reader, &field)?),
Some(2) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
Some(3) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(4) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
hue: hue.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
saturation: saturation.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MoveToColorFields {
pub color_x: u16,
pub color_y: u16,
pub transition_time: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for MoveToColorFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.color_x.to_tlv(w, Tag::Context(0))?;
self.color_y.to_tlv(w, Tag::Context(1))?;
self.transition_time.to_tlv(w, Tag::Context(2))?;
self.options_mask.to_tlv(w, Tag::Context(3))?;
self.options_override.to_tlv(w, Tag::Context(4))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for MoveToColorFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut color_x = None;
let mut color_y = None;
let mut transition_time = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => color_x = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => color_y = Some(<u16>::from_tlv(reader, &field)?),
Some(2) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
Some(3) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(4) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
color_x: color_x.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
color_y: color_y.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MoveColorFields {
pub rate_x: i16,
pub rate_y: i16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for MoveColorFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.rate_x.to_tlv(w, Tag::Context(0))?;
self.rate_y.to_tlv(w, Tag::Context(1))?;
self.options_mask.to_tlv(w, Tag::Context(2))?;
self.options_override.to_tlv(w, Tag::Context(3))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for MoveColorFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut rate_x = None;
let mut rate_y = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => rate_x = Some(<i16>::from_tlv(reader, &field)?),
Some(1) => rate_y = Some(<i16>::from_tlv(reader, &field)?),
Some(2) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(3) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
rate_x: rate_x.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
rate_y: rate_y.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct StepColorFields {
pub step_x: i16,
pub step_y: i16,
pub transition_time: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for StepColorFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.step_x.to_tlv(w, Tag::Context(0))?;
self.step_y.to_tlv(w, Tag::Context(1))?;
self.transition_time.to_tlv(w, Tag::Context(2))?;
self.options_mask.to_tlv(w, Tag::Context(3))?;
self.options_override.to_tlv(w, Tag::Context(4))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for StepColorFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut step_x = None;
let mut step_y = None;
let mut transition_time = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => step_x = Some(<i16>::from_tlv(reader, &field)?),
Some(1) => step_y = Some(<i16>::from_tlv(reader, &field)?),
Some(2) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
Some(3) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(4) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
step_x: step_x.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
step_y: step_y.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MoveToColorTemperatureFields {
pub color_temperature_mireds: u16,
pub transition_time: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for MoveToColorTemperatureFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.color_temperature_mireds.to_tlv(w, Tag::Context(0))?;
self.transition_time.to_tlv(w, Tag::Context(1))?;
self.options_mask.to_tlv(w, Tag::Context(2))?;
self.options_override.to_tlv(w, Tag::Context(3))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for MoveToColorTemperatureFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut color_temperature_mireds = None;
let mut transition_time = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => color_temperature_mireds = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
Some(2) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(3) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
color_temperature_mireds: color_temperature_mireds
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct EnhancedMoveToHueFields {
pub enhanced_hue: u16,
pub direction: DirectionEnum,
pub transition_time: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for EnhancedMoveToHueFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.enhanced_hue.to_tlv(w, Tag::Context(0))?;
self.direction.to_tlv(w, Tag::Context(1))?;
self.transition_time.to_tlv(w, Tag::Context(2))?;
self.options_mask.to_tlv(w, Tag::Context(3))?;
self.options_override.to_tlv(w, Tag::Context(4))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for EnhancedMoveToHueFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut enhanced_hue = None;
let mut direction = None;
let mut transition_time = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => enhanced_hue = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => direction = Some(<DirectionEnum>::from_tlv(reader, &field)?),
Some(2) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
Some(3) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(4) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
enhanced_hue: enhanced_hue.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
direction: direction.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct EnhancedMoveHueFields {
pub move_mode: MoveModeEnum,
pub rate: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for EnhancedMoveHueFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.move_mode.to_tlv(w, Tag::Context(0))?;
self.rate.to_tlv(w, Tag::Context(1))?;
self.options_mask.to_tlv(w, Tag::Context(2))?;
self.options_override.to_tlv(w, Tag::Context(3))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for EnhancedMoveHueFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut move_mode = None;
let mut rate = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => move_mode = Some(<MoveModeEnum>::from_tlv(reader, &field)?),
Some(1) => rate = Some(<u16>::from_tlv(reader, &field)?),
Some(2) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(3) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
move_mode: move_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
rate: rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct EnhancedStepHueFields {
pub step_mode: StepModeEnum,
pub step_size: u16,
pub transition_time: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for EnhancedStepHueFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.step_mode.to_tlv(w, Tag::Context(0))?;
self.step_size.to_tlv(w, Tag::Context(1))?;
self.transition_time.to_tlv(w, Tag::Context(2))?;
self.options_mask.to_tlv(w, Tag::Context(3))?;
self.options_override.to_tlv(w, Tag::Context(4))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for EnhancedStepHueFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut step_mode = None;
let mut step_size = None;
let mut transition_time = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => step_mode = Some(<StepModeEnum>::from_tlv(reader, &field)?),
Some(1) => step_size = Some(<u16>::from_tlv(reader, &field)?),
Some(2) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
Some(3) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(4) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
step_mode: step_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
step_size: step_size.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct EnhancedMoveToHueAndSaturationFields {
pub enhanced_hue: u16,
pub saturation: u8,
pub transition_time: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for EnhancedMoveToHueAndSaturationFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.enhanced_hue.to_tlv(w, Tag::Context(0))?;
self.saturation.to_tlv(w, Tag::Context(1))?;
self.transition_time.to_tlv(w, Tag::Context(2))?;
self.options_mask.to_tlv(w, Tag::Context(3))?;
self.options_override.to_tlv(w, Tag::Context(4))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for EnhancedMoveToHueAndSaturationFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut enhanced_hue = None;
let mut saturation = None;
let mut transition_time = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => enhanced_hue = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => saturation = Some(<u8>::from_tlv(reader, &field)?),
Some(2) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
Some(3) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(4) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
enhanced_hue: enhanced_hue.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
saturation: saturation.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ColorLoopSetFields {
pub update_flags: UpdateFlagsBitmap,
pub action: ColorLoopActionEnum,
pub direction: ColorLoopDirectionEnum,
pub time: u16,
pub start_hue: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for ColorLoopSetFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.update_flags.to_tlv(w, Tag::Context(0))?;
self.action.to_tlv(w, Tag::Context(1))?;
self.direction.to_tlv(w, Tag::Context(2))?;
self.time.to_tlv(w, Tag::Context(3))?;
self.start_hue.to_tlv(w, Tag::Context(4))?;
self.options_mask.to_tlv(w, Tag::Context(5))?;
self.options_override.to_tlv(w, Tag::Context(6))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for ColorLoopSetFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut update_flags = None;
let mut action = None;
let mut direction = None;
let mut time = None;
let mut start_hue = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => update_flags = Some(<UpdateFlagsBitmap>::from_tlv(reader, &field)?),
Some(1) => action = Some(<ColorLoopActionEnum>::from_tlv(reader, &field)?),
Some(2) => direction = Some(<ColorLoopDirectionEnum>::from_tlv(reader, &field)?),
Some(3) => time = Some(<u16>::from_tlv(reader, &field)?),
Some(4) => start_hue = Some(<u16>::from_tlv(reader, &field)?),
Some(5) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(6) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
update_flags: update_flags.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
action: action.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
direction: direction.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
time: time.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
start_hue: start_hue.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct StopMoveStepFields {
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for StopMoveStepFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.options_mask.to_tlv(w, Tag::Context(0))?;
self.options_override.to_tlv(w, Tag::Context(1))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for StopMoveStepFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(1) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MoveColorTemperatureFields {
pub move_mode: MoveModeEnum,
pub rate: u16,
pub color_temperature_minimum_mireds: u16,
pub color_temperature_maximum_mireds: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for MoveColorTemperatureFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.move_mode.to_tlv(w, Tag::Context(0))?;
self.rate.to_tlv(w, Tag::Context(1))?;
self.color_temperature_minimum_mireds
.to_tlv(w, Tag::Context(2))?;
self.color_temperature_maximum_mireds
.to_tlv(w, Tag::Context(3))?;
self.options_mask.to_tlv(w, Tag::Context(4))?;
self.options_override.to_tlv(w, Tag::Context(5))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for MoveColorTemperatureFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut move_mode = None;
let mut rate = None;
let mut color_temperature_minimum_mireds = None;
let mut color_temperature_maximum_mireds = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => move_mode = Some(<MoveModeEnum>::from_tlv(reader, &field)?),
Some(1) => rate = Some(<u16>::from_tlv(reader, &field)?),
Some(2) => {
color_temperature_minimum_mireds = Some(<u16>::from_tlv(reader, &field)?)
}
Some(3) => {
color_temperature_maximum_mireds = Some(<u16>::from_tlv(reader, &field)?)
}
Some(4) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(5) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
move_mode: move_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
rate: rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
color_temperature_minimum_mireds: color_temperature_minimum_mireds
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
color_temperature_maximum_mireds: color_temperature_maximum_mireds
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct StepColorTemperatureFields {
pub step_mode: StepModeEnum,
pub step_size: u16,
pub transition_time: u16,
pub color_temperature_minimum_mireds: u16,
pub color_temperature_maximum_mireds: u16,
pub options_mask: OptionsBitmap,
pub options_override: OptionsBitmap,
}
impl ToTlv for StepColorTemperatureFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.step_mode.to_tlv(w, Tag::Context(0))?;
self.step_size.to_tlv(w, Tag::Context(1))?;
self.transition_time.to_tlv(w, Tag::Context(2))?;
self.color_temperature_minimum_mireds
.to_tlv(w, Tag::Context(3))?;
self.color_temperature_maximum_mireds
.to_tlv(w, Tag::Context(4))?;
self.options_mask.to_tlv(w, Tag::Context(5))?;
self.options_override.to_tlv(w, Tag::Context(6))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for StepColorTemperatureFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut step_mode = None;
let mut step_size = None;
let mut transition_time = None;
let mut color_temperature_minimum_mireds = None;
let mut color_temperature_maximum_mireds = None;
let mut options_mask = None;
let mut options_override = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => step_mode = Some(<StepModeEnum>::from_tlv(reader, &field)?),
Some(1) => step_size = Some(<u16>::from_tlv(reader, &field)?),
Some(2) => transition_time = Some(<u16>::from_tlv(reader, &field)?),
Some(3) => {
color_temperature_minimum_mireds = Some(<u16>::from_tlv(reader, &field)?)
}
Some(4) => {
color_temperature_maximum_mireds = Some(<u16>::from_tlv(reader, &field)?)
}
Some(5) => options_mask = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
Some(6) => options_override = Some(<OptionsBitmap>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
step_mode: step_mode.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
step_size: step_size.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
transition_time: transition_time
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
color_temperature_minimum_mireds: color_temperature_minimum_mireds
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
color_temperature_maximum_mireds: color_temperature_maximum_mireds
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_mask: options_mask.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
options_override: options_override
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
pub const ATTRIBUTES: &[Attribute] = &[
Attribute {
id: 0x0000,
name: "CurrentHue",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::Quieter,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0001,
name: "CurrentSaturation",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE.union(AttributeQualities::SCENE),
reporting: Reporting::Quieter,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0002,
name: "RemainingTime",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::Quieter,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0003,
name: "CurrentX",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE.union(AttributeQualities::SCENE),
reporting: Reporting::Quieter,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(3),
}],
},
},
Attribute {
id: 0x0004,
name: "CurrentY",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE.union(AttributeQualities::SCENE),
reporting: Reporting::Quieter,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(3),
}],
},
},
Attribute {
id: 0x0005,
name: "DriftCompensation",
kind: "DriftCompensationEnum",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0006,
name: "CompensationText",
kind: "string",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0007,
name: "ColorTemperatureMireds",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE.union(AttributeQualities::SCENE),
reporting: Reporting::Quieter,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x0008,
name: "ColorMode",
kind: "ColorModeEnum",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x000F,
name: "Options",
kind: "OptionsBitmap",
access: Access::read_write_with(Privilege::View, Privilege::Operate),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0010,
name: "NumberOfPrimaries",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::FIXED),
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0011,
name: "Primary1X",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0012,
name: "Primary1Y",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0013,
name: "Primary1Intensity",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::FIXED),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0015,
name: "Primary2X",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0016,
name: "Primary2Y",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0017,
name: "Primary2Intensity",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::FIXED),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0019,
name: "Primary3X",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x001A,
name: "Primary3Y",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x001B,
name: "Primary3Intensity",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::FIXED),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0020,
name: "Primary4X",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0021,
name: "Primary4Y",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0022,
name: "Primary4Intensity",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::FIXED),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0024,
name: "Primary5X",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0025,
name: "Primary5Y",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0026,
name: "Primary5Intensity",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::FIXED),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0028,
name: "Primary6X",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0029,
name: "Primary6Y",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x002A,
name: "Primary6Intensity",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::FIXED),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Described,
when: Condition::Named("comparison"),
},
Clause {
verdict: Conformance::Optional,
when: Condition::Always,
},
],
},
},
Attribute {
id: 0x0030,
name: "WhitePointX",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0031,
name: "WhitePointY",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0032,
name: "ColorPointRX",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0033,
name: "ColorPointRY",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0034,
name: "ColorPointRIntensity",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0036,
name: "ColorPointGX",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0037,
name: "ColorPointGY",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0038,
name: "ColorPointGIntensity",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x003A,
name: "ColorPointBX",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x003B,
name: "ColorPointBY",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x003C,
name: "ColorPointBIntensity",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NULLABLE,
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x4000,
name: "EnhancedCurrentHue",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE.union(AttributeQualities::SCENE),
reporting: Reporting::Quieter,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Attribute {
id: 0x4001,
name: "EnhancedColorMode",
kind: "EnhancedColorModeEnum",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE.union(AttributeQualities::SCENE),
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x4002,
name: "ColorLoopActive",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE.union(AttributeQualities::SCENE),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Attribute {
id: 0x4003,
name: "ColorLoopDirection",
kind: "ColorLoopDirectionEnum",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE.union(AttributeQualities::SCENE),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Attribute {
id: 0x4004,
name: "ColorLoopTime",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE.union(AttributeQualities::SCENE),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Attribute {
id: 0x4005,
name: "ColorLoopStartEnhancedHue",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Attribute {
id: 0x4006,
name: "ColorLoopStoredEnhancedHue",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Attribute {
id: 0x400A,
name: "ColorCapabilities",
kind: "ColorCapabilitiesBitmap",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x400B,
name: "ColorTempPhysicalMinMireds",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x400C,
name: "ColorTempPhysicalMaxMireds",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x400D,
name: "CoupleColorTempToLevelMinMireds",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x4010,
name: "StartUpColorTemperatureMireds",
kind: "uint16",
access: Access::read_write_with(Privilege::View, Privilege::Manage),
qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
];
pub const COMMANDS: &[Command] = &[
Command {
id: 0x00,
name: "MoveToHue",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x01,
name: "MoveHue",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x02,
name: "StepHue",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x03,
name: "MoveToSaturation",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x04,
name: "MoveSaturation",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x05,
name: "StepSaturation",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x06,
name: "MoveToHueAndSaturation",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x07,
name: "MoveToColor",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(3),
}],
},
},
Command {
id: 0x08,
name: "MoveColor",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(3),
}],
},
},
Command {
id: 0x09,
name: "StepColor",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(3),
}],
},
},
Command {
id: 0x0A,
name: "MoveToColorTemperature",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Command {
id: 0x40,
name: "EnhancedMoveToHue",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Command {
id: 0x41,
name: "EnhancedMoveHue",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Command {
id: 0x42,
name: "EnhancedStepHue",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Command {
id: 0x43,
name: "EnhancedMoveToHueAndSaturation",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Command {
id: 0x44,
name: "ColorLoopSet",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Command {
id: 0x47,
name: "StopMoveStep",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Any(&[
Condition::Feature(0),
Condition::Feature(3),
Condition::Feature(4),
]),
}],
},
},
Command {
id: 0x4B,
name: "MoveColorTemperature",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Command {
id: 0x4C,
name: "StepColorTemperature",
to_server: true,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
];
pub const EVENTS: &[Event] = &[];
pub const CLUSTER: Cluster = Cluster {
id: ID,
name: "Color Control",
revision: REVISION,
pics: "CC",
derived_from: None,
features: FEATURES,
attributes: ATTRIBUTES,
commands: COMMANDS,
events: EVENTS,
};