1#![allow(unused_imports)]
15
16use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
17use crate::dm::meta::{EventPriority, Reporting};
18use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
19use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
20use crate::error::Result;
21use crate::im::{AttributeId, ClusterId, CommandId, EventId};
22use crate::tlv::{
23 ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
24};
25
26pub const ID: ClusterId = 0x002F;
28
29pub const REVISION: u16 = 3;
32
33pub const PICS: &str = "PS";
35
36pub mod feature {
41 pub const WIRED: u32 = 1 << 0;
45 pub const BATTERY: u32 = 1 << 1;
49 pub const RECHARGEABLE: u32 = 1 << 2;
53 pub const REPLACEABLE: u32 = 1 << 3;
57}
58
59pub const FEATURES: &[Feature] = &[
61 Feature {
62 bit: 0,
63 code: "WIRED",
64 name: "Wired",
65 conform: Conform::OPTIONAL,
66 },
67 Feature {
68 bit: 1,
69 code: "BAT",
70 name: "Battery",
71 conform: Conform::OPTIONAL,
72 },
73 Feature {
74 bit: 2,
75 code: "RECHG",
76 name: "Rechargeable",
77 conform: Conform {
78 clauses: &[Clause {
79 verdict: Conformance::Optional,
80 when: Condition::Feature(1),
81 }],
82 },
83 },
84 Feature {
85 bit: 3,
86 code: "REPLC",
87 name: "Replaceable",
88 conform: Conform {
89 clauses: &[Clause {
90 verdict: Conformance::Optional,
91 when: Condition::Feature(1),
92 }],
93 },
94 },
95];
96
97pub mod attribute {
99 use crate::im::AttributeId;
100
101 pub const STATUS: AttributeId = 0x00;
103 pub const ORDER: AttributeId = 0x01;
105 pub const DESCRIPTION: AttributeId = 0x02;
107 pub const WIRED_ASSESSED_INPUT_VOLTAGE: AttributeId = 0x03;
109 pub const WIRED_ASSESSED_INPUT_FREQUENCY: AttributeId = 0x04;
111 pub const WIRED_CURRENT_TYPE: AttributeId = 0x05;
113 pub const WIRED_ASSESSED_CURRENT: AttributeId = 0x06;
115 pub const WIRED_NOMINAL_VOLTAGE: AttributeId = 0x07;
117 pub const WIRED_MAXIMUM_CURRENT: AttributeId = 0x08;
119 pub const WIRED_PRESENT: AttributeId = 0x09;
121 pub const ACTIVE_WIRED_FAULTS: AttributeId = 0x0A;
123 pub const BAT_VOLTAGE: AttributeId = 0x0B;
125 pub const BAT_PERCENT_REMAINING: AttributeId = 0x0C;
127 pub const BAT_TIME_REMAINING: AttributeId = 0x0D;
129 pub const BAT_CHARGE_LEVEL: AttributeId = 0x0E;
131 pub const BAT_REPLACEMENT_NEEDED: AttributeId = 0x0F;
133 pub const BAT_REPLACEABILITY: AttributeId = 0x10;
135 pub const BAT_PRESENT: AttributeId = 0x11;
137 pub const ACTIVE_BAT_FAULTS: AttributeId = 0x12;
139 pub const BAT_REPLACEMENT_DESCRIPTION: AttributeId = 0x13;
141 pub const BAT_COMMON_DESIGNATION: AttributeId = 0x14;
143 pub const BAT_ANSI_DESIGNATION: AttributeId = 0x15;
145 pub const BAT_IEC_DESIGNATION: AttributeId = 0x16;
147 pub const BAT_APPROVED_CHEMISTRY: AttributeId = 0x17;
149 pub const BAT_CAPACITY: AttributeId = 0x18;
151 pub const BAT_QUANTITY: AttributeId = 0x19;
153 pub const BAT_CHARGE_STATE: AttributeId = 0x1A;
155 pub const BAT_TIME_TO_FULL_CHARGE: AttributeId = 0x1B;
157 pub const BAT_FUNCTIONAL_WHILE_CHARGING: AttributeId = 0x1C;
159 pub const BAT_CHARGING_CURRENT: AttributeId = 0x1D;
161 pub const ACTIVE_BAT_CHARGE_FAULTS: AttributeId = 0x1E;
163 pub const ENDPOINT_LIST: AttributeId = 0x1F;
165}
166
167pub mod event {
169 use crate::im::EventId;
170
171 pub const WIRED_FAULT_CHANGE: EventId = 0x00;
173 pub const BAT_FAULT_CHANGE: EventId = 0x01;
175 pub const BAT_CHARGE_FAULT_CHANGE: EventId = 0x02;
177}
178
179#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
181#[repr(u8)]
182pub enum BatApprovedChemistryEnum {
183 Unspecified = 0,
185 Alkaline = 1,
187 LithiumCarbonFluoride = 2,
189 LithiumChromiumOxide = 3,
191 LithiumCopperOxide = 4,
193 LithiumIronDisulfide = 5,
195 LithiumManganeseDioxide = 6,
197 LithiumThionylChloride = 7,
199 Magnesium = 8,
201 MercuryOxide = 9,
203 NickelOxyhydride = 10,
205 SilverOxide = 11,
207 ZincAir = 12,
209 ZincCarbon = 13,
211 ZincChloride = 14,
213 ZincManganeseDioxide = 15,
215 LeadAcid = 16,
217 LithiumCobaltOxide = 17,
219 LithiumIon = 18,
221 LithiumIonPolymer = 19,
223 LithiumIronPhosphate = 20,
225 LithiumSulfur = 21,
227 LithiumTitanate = 22,
229 NickelCadmium = 23,
231 NickelHydrogen = 24,
233 NickelIron = 25,
235 NickelMetalHydride = 26,
237 NickelZinc = 27,
239 SilverZinc = 28,
241 SodiumIon = 29,
243 SodiumSulfur = 30,
245 ZincBromide = 31,
247 ZincCerium = 32,
249}
250
251impl BatApprovedChemistryEnum {
252 #[must_use]
254 pub const fn from_value(value: u8) -> Option<Self> {
255 match value {
256 0 => Some(Self::Unspecified),
257 1 => Some(Self::Alkaline),
258 2 => Some(Self::LithiumCarbonFluoride),
259 3 => Some(Self::LithiumChromiumOxide),
260 4 => Some(Self::LithiumCopperOxide),
261 5 => Some(Self::LithiumIronDisulfide),
262 6 => Some(Self::LithiumManganeseDioxide),
263 7 => Some(Self::LithiumThionylChloride),
264 8 => Some(Self::Magnesium),
265 9 => Some(Self::MercuryOxide),
266 10 => Some(Self::NickelOxyhydride),
267 11 => Some(Self::SilverOxide),
268 12 => Some(Self::ZincAir),
269 13 => Some(Self::ZincCarbon),
270 14 => Some(Self::ZincChloride),
271 15 => Some(Self::ZincManganeseDioxide),
272 16 => Some(Self::LeadAcid),
273 17 => Some(Self::LithiumCobaltOxide),
274 18 => Some(Self::LithiumIon),
275 19 => Some(Self::LithiumIonPolymer),
276 20 => Some(Self::LithiumIronPhosphate),
277 21 => Some(Self::LithiumSulfur),
278 22 => Some(Self::LithiumTitanate),
279 23 => Some(Self::NickelCadmium),
280 24 => Some(Self::NickelHydrogen),
281 25 => Some(Self::NickelIron),
282 26 => Some(Self::NickelMetalHydride),
283 27 => Some(Self::NickelZinc),
284 28 => Some(Self::SilverZinc),
285 29 => Some(Self::SodiumIon),
286 30 => Some(Self::SodiumSulfur),
287 31 => Some(Self::ZincBromide),
288 32 => Some(Self::ZincCerium),
289 _ => None,
290 }
291 }
292
293 #[must_use]
295 pub const fn value(self) -> u8 {
296 self as u8
297 }
298}
299
300impl ToTlv for BatApprovedChemistryEnum {
301 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
302 self.value().to_tlv(w, tag)
303 }
304}
305
306impl<'a> FromTlv<'a> for BatApprovedChemistryEnum {
307 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
308 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
309 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
310 }
311}
312
313#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
315#[repr(u8)]
316pub enum BatChargeFaultEnum {
317 Unspecified = 0,
319 AmbientTooHot = 1,
321 AmbientTooCold = 2,
323 BatteryTooHot = 3,
325 BatteryTooCold = 4,
327 BatteryAbsent = 5,
329 BatteryOverVoltage = 6,
331 BatteryUnderVoltage = 7,
333 ChargerOverVoltage = 8,
335 ChargerUnderVoltage = 9,
337 SafetyTimeout = 10,
339}
340
341impl BatChargeFaultEnum {
342 #[must_use]
344 pub const fn from_value(value: u8) -> Option<Self> {
345 match value {
346 0 => Some(Self::Unspecified),
347 1 => Some(Self::AmbientTooHot),
348 2 => Some(Self::AmbientTooCold),
349 3 => Some(Self::BatteryTooHot),
350 4 => Some(Self::BatteryTooCold),
351 5 => Some(Self::BatteryAbsent),
352 6 => Some(Self::BatteryOverVoltage),
353 7 => Some(Self::BatteryUnderVoltage),
354 8 => Some(Self::ChargerOverVoltage),
355 9 => Some(Self::ChargerUnderVoltage),
356 10 => Some(Self::SafetyTimeout),
357 _ => None,
358 }
359 }
360
361 #[must_use]
363 pub const fn value(self) -> u8 {
364 self as u8
365 }
366}
367
368impl ToTlv for BatChargeFaultEnum {
369 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
370 self.value().to_tlv(w, tag)
371 }
372}
373
374impl<'a> FromTlv<'a> for BatChargeFaultEnum {
375 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
376 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
377 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
378 }
379}
380
381#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
383#[repr(u8)]
384pub enum BatChargeLevelEnum {
385 OK = 0,
387 Warning = 1,
389 Critical = 2,
391}
392
393impl BatChargeLevelEnum {
394 #[must_use]
396 pub const fn from_value(value: u8) -> Option<Self> {
397 match value {
398 0 => Some(Self::OK),
399 1 => Some(Self::Warning),
400 2 => Some(Self::Critical),
401 _ => None,
402 }
403 }
404
405 #[must_use]
407 pub const fn value(self) -> u8 {
408 self as u8
409 }
410}
411
412impl ToTlv for BatChargeLevelEnum {
413 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
414 self.value().to_tlv(w, tag)
415 }
416}
417
418impl<'a> FromTlv<'a> for BatChargeLevelEnum {
419 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
420 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
421 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
422 }
423}
424
425#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
427#[repr(u8)]
428pub enum BatChargeStateEnum {
429 Unknown = 0,
431 IsCharging = 1,
433 IsAtFullCharge = 2,
435 IsNotCharging = 3,
437}
438
439impl BatChargeStateEnum {
440 #[must_use]
442 pub const fn from_value(value: u8) -> Option<Self> {
443 match value {
444 0 => Some(Self::Unknown),
445 1 => Some(Self::IsCharging),
446 2 => Some(Self::IsAtFullCharge),
447 3 => Some(Self::IsNotCharging),
448 _ => None,
449 }
450 }
451
452 #[must_use]
454 pub const fn value(self) -> u8 {
455 self as u8
456 }
457}
458
459impl ToTlv for BatChargeStateEnum {
460 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
461 self.value().to_tlv(w, tag)
462 }
463}
464
465impl<'a> FromTlv<'a> for BatChargeStateEnum {
466 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
467 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
468 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
469 }
470}
471
472#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
474#[repr(u8)]
475pub enum BatCommonDesignationEnum {
476 Unspecified = 0,
478 AAA = 1,
480 AA = 2,
482 C = 3,
484 D = 4,
486 N4V5 = 5,
488 N6V0 = 6,
490 N9V0 = 7,
492 N12AA = 8,
494 AAAA = 9,
496 A = 10,
498 B = 11,
500 F = 12,
502 N = 13,
504 No6 = 14,
506 SubC = 15,
508 A23 = 16,
510 A27 = 17,
512 BA5800 = 18,
514 Duplex = 19,
516 N4SR44 = 20,
518 N523 = 21,
520 N531 = 22,
522 N15V0 = 23,
524 N22V5 = 24,
526 N30V0 = 25,
528 N45V0 = 26,
530 N67V5 = 27,
532 J = 28,
534 CR123A = 29,
536 CR2 = 30,
538 N2CR5 = 31,
540 CRP2 = 32,
542 CRV3 = 33,
544 SR41 = 34,
546 SR43 = 35,
548 SR44 = 36,
550 SR45 = 37,
552 SR48 = 38,
554 SR54 = 39,
556 SR55 = 40,
558 SR57 = 41,
560 SR58 = 42,
562 SR59 = 43,
564 SR60 = 44,
566 SR63 = 45,
568 SR64 = 46,
570 SR65 = 47,
572 SR66 = 48,
574 SR67 = 49,
576 SR68 = 50,
578 SR69 = 51,
580 SR516 = 52,
582 SR731 = 53,
584 SR712 = 54,
586 LR932 = 55,
588 A5 = 56,
590 A10 = 57,
592 A13 = 58,
594 A312 = 59,
596 A675 = 60,
598 AC41E = 61,
600 N10180 = 62,
602 N10280 = 63,
604 N10440 = 64,
606 N14250 = 65,
608 N14430 = 66,
610 N14500 = 67,
612 N14650 = 68,
614 N15270 = 69,
616 N16340 = 70,
618 RCR123A = 71,
620 N17500 = 72,
622 N17670 = 73,
624 N18350 = 74,
626 N18500 = 75,
628 N18650 = 76,
630 N19670 = 77,
632 N25500 = 78,
634 N26650 = 79,
636 N32600 = 80,
638}
639
640impl BatCommonDesignationEnum {
641 #[must_use]
643 pub const fn from_value(value: u8) -> Option<Self> {
644 match value {
645 0 => Some(Self::Unspecified),
646 1 => Some(Self::AAA),
647 2 => Some(Self::AA),
648 3 => Some(Self::C),
649 4 => Some(Self::D),
650 5 => Some(Self::N4V5),
651 6 => Some(Self::N6V0),
652 7 => Some(Self::N9V0),
653 8 => Some(Self::N12AA),
654 9 => Some(Self::AAAA),
655 10 => Some(Self::A),
656 11 => Some(Self::B),
657 12 => Some(Self::F),
658 13 => Some(Self::N),
659 14 => Some(Self::No6),
660 15 => Some(Self::SubC),
661 16 => Some(Self::A23),
662 17 => Some(Self::A27),
663 18 => Some(Self::BA5800),
664 19 => Some(Self::Duplex),
665 20 => Some(Self::N4SR44),
666 21 => Some(Self::N523),
667 22 => Some(Self::N531),
668 23 => Some(Self::N15V0),
669 24 => Some(Self::N22V5),
670 25 => Some(Self::N30V0),
671 26 => Some(Self::N45V0),
672 27 => Some(Self::N67V5),
673 28 => Some(Self::J),
674 29 => Some(Self::CR123A),
675 30 => Some(Self::CR2),
676 31 => Some(Self::N2CR5),
677 32 => Some(Self::CRP2),
678 33 => Some(Self::CRV3),
679 34 => Some(Self::SR41),
680 35 => Some(Self::SR43),
681 36 => Some(Self::SR44),
682 37 => Some(Self::SR45),
683 38 => Some(Self::SR48),
684 39 => Some(Self::SR54),
685 40 => Some(Self::SR55),
686 41 => Some(Self::SR57),
687 42 => Some(Self::SR58),
688 43 => Some(Self::SR59),
689 44 => Some(Self::SR60),
690 45 => Some(Self::SR63),
691 46 => Some(Self::SR64),
692 47 => Some(Self::SR65),
693 48 => Some(Self::SR66),
694 49 => Some(Self::SR67),
695 50 => Some(Self::SR68),
696 51 => Some(Self::SR69),
697 52 => Some(Self::SR516),
698 53 => Some(Self::SR731),
699 54 => Some(Self::SR712),
700 55 => Some(Self::LR932),
701 56 => Some(Self::A5),
702 57 => Some(Self::A10),
703 58 => Some(Self::A13),
704 59 => Some(Self::A312),
705 60 => Some(Self::A675),
706 61 => Some(Self::AC41E),
707 62 => Some(Self::N10180),
708 63 => Some(Self::N10280),
709 64 => Some(Self::N10440),
710 65 => Some(Self::N14250),
711 66 => Some(Self::N14430),
712 67 => Some(Self::N14500),
713 68 => Some(Self::N14650),
714 69 => Some(Self::N15270),
715 70 => Some(Self::N16340),
716 71 => Some(Self::RCR123A),
717 72 => Some(Self::N17500),
718 73 => Some(Self::N17670),
719 74 => Some(Self::N18350),
720 75 => Some(Self::N18500),
721 76 => Some(Self::N18650),
722 77 => Some(Self::N19670),
723 78 => Some(Self::N25500),
724 79 => Some(Self::N26650),
725 80 => Some(Self::N32600),
726 _ => None,
727 }
728 }
729
730 #[must_use]
732 pub const fn value(self) -> u8 {
733 self as u8
734 }
735}
736
737impl ToTlv for BatCommonDesignationEnum {
738 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
739 self.value().to_tlv(w, tag)
740 }
741}
742
743impl<'a> FromTlv<'a> for BatCommonDesignationEnum {
744 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
745 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
746 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
747 }
748}
749
750#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
752#[repr(u8)]
753pub enum BatFaultEnum {
754 Unspecified = 0,
756 OverTemp = 1,
758 UnderTemp = 2,
760}
761
762impl BatFaultEnum {
763 #[must_use]
765 pub const fn from_value(value: u8) -> Option<Self> {
766 match value {
767 0 => Some(Self::Unspecified),
768 1 => Some(Self::OverTemp),
769 2 => Some(Self::UnderTemp),
770 _ => None,
771 }
772 }
773
774 #[must_use]
776 pub const fn value(self) -> u8 {
777 self as u8
778 }
779}
780
781impl ToTlv for BatFaultEnum {
782 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
783 self.value().to_tlv(w, tag)
784 }
785}
786
787impl<'a> FromTlv<'a> for BatFaultEnum {
788 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
789 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
790 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
791 }
792}
793
794#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
796#[repr(u8)]
797pub enum BatReplaceabilityEnum {
798 Unspecified = 0,
800 NotReplaceable = 1,
802 UserReplaceable = 2,
804 FactoryReplaceable = 3,
806}
807
808impl BatReplaceabilityEnum {
809 #[must_use]
811 pub const fn from_value(value: u8) -> Option<Self> {
812 match value {
813 0 => Some(Self::Unspecified),
814 1 => Some(Self::NotReplaceable),
815 2 => Some(Self::UserReplaceable),
816 3 => Some(Self::FactoryReplaceable),
817 _ => None,
818 }
819 }
820
821 #[must_use]
823 pub const fn value(self) -> u8 {
824 self as u8
825 }
826}
827
828impl ToTlv for BatReplaceabilityEnum {
829 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
830 self.value().to_tlv(w, tag)
831 }
832}
833
834impl<'a> FromTlv<'a> for BatReplaceabilityEnum {
835 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
836 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
837 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
838 }
839}
840
841#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
843#[repr(u8)]
844pub enum PowerSourceStatusEnum {
845 Unspecified = 0,
847 Active = 1,
849 Standby = 2,
851 Unavailable = 3,
853}
854
855impl PowerSourceStatusEnum {
856 #[must_use]
858 pub const fn from_value(value: u8) -> Option<Self> {
859 match value {
860 0 => Some(Self::Unspecified),
861 1 => Some(Self::Active),
862 2 => Some(Self::Standby),
863 3 => Some(Self::Unavailable),
864 _ => None,
865 }
866 }
867
868 #[must_use]
870 pub const fn value(self) -> u8 {
871 self as u8
872 }
873}
874
875impl ToTlv for PowerSourceStatusEnum {
876 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
877 self.value().to_tlv(w, tag)
878 }
879}
880
881impl<'a> FromTlv<'a> for PowerSourceStatusEnum {
882 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
883 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
884 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
885 }
886}
887
888#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
890#[repr(u8)]
891pub enum WiredCurrentTypeEnum {
892 AC = 0,
894 DC = 1,
896}
897
898impl WiredCurrentTypeEnum {
899 #[must_use]
901 pub const fn from_value(value: u8) -> Option<Self> {
902 match value {
903 0 => Some(Self::AC),
904 1 => Some(Self::DC),
905 _ => None,
906 }
907 }
908
909 #[must_use]
911 pub const fn value(self) -> u8 {
912 self as u8
913 }
914}
915
916impl ToTlv for WiredCurrentTypeEnum {
917 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
918 self.value().to_tlv(w, tag)
919 }
920}
921
922impl<'a> FromTlv<'a> for WiredCurrentTypeEnum {
923 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
924 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
925 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
926 }
927}
928
929#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
931#[repr(u8)]
932pub enum WiredFaultEnum {
933 Unspecified = 0,
935 OverVoltage = 1,
937 UnderVoltage = 2,
939}
940
941impl WiredFaultEnum {
942 #[must_use]
944 pub const fn from_value(value: u8) -> Option<Self> {
945 match value {
946 0 => Some(Self::Unspecified),
947 1 => Some(Self::OverVoltage),
948 2 => Some(Self::UnderVoltage),
949 _ => None,
950 }
951 }
952
953 #[must_use]
955 pub const fn value(self) -> u8 {
956 self as u8
957 }
958}
959
960impl ToTlv for WiredFaultEnum {
961 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
962 self.value().to_tlv(w, tag)
963 }
964}
965
966impl<'a> FromTlv<'a> for WiredFaultEnum {
967 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
968 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
969 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
970 }
971}
972
973pub const ATTRIBUTES: &[Attribute] = &[
975 Attribute {
976 id: 0x0000,
977 name: "Status",
978 kind: "PowerSourceStatusEnum",
979 access: Access::read_only(Privilege::View),
980 qualities: AttributeQualities::empty(),
981 reporting: Reporting::OnChange,
982 conform: Conform::MANDATORY,
983 },
984 Attribute {
985 id: 0x0001,
986 name: "Order",
987 kind: "uint8",
988 access: Access::read_only(Privilege::View),
989 qualities: AttributeQualities::NON_VOLATILE,
990 reporting: Reporting::OnChange,
991 conform: Conform::MANDATORY,
992 },
993 Attribute {
994 id: 0x0002,
995 name: "Description",
996 kind: "string",
997 access: Access::read_only(Privilege::View),
998 qualities: AttributeQualities::FIXED,
999 reporting: Reporting::OnChange,
1000 conform: Conform::MANDATORY,
1001 },
1002 Attribute {
1003 id: 0x0003,
1004 name: "WiredAssessedInputVoltage",
1005 kind: "uint32",
1006 access: Access::read_only(Privilege::View),
1007 qualities: AttributeQualities::NULLABLE,
1008 reporting: Reporting::ChangesOmitted,
1009 conform: Conform {
1010 clauses: &[Clause {
1011 verdict: Conformance::Optional,
1012 when: Condition::Feature(0),
1013 }],
1014 },
1015 },
1016 Attribute {
1017 id: 0x0004,
1018 name: "WiredAssessedInputFrequency",
1019 kind: "uint16",
1020 access: Access::read_only(Privilege::View),
1021 qualities: AttributeQualities::NULLABLE,
1022 reporting: Reporting::ChangesOmitted,
1023 conform: Conform {
1024 clauses: &[Clause {
1025 verdict: Conformance::Optional,
1026 when: Condition::Feature(0),
1027 }],
1028 },
1029 },
1030 Attribute {
1031 id: 0x0005,
1032 name: "WiredCurrentType",
1033 kind: "WiredCurrentTypeEnum",
1034 access: Access::read_only(Privilege::View),
1035 qualities: AttributeQualities::FIXED,
1036 reporting: Reporting::OnChange,
1037 conform: Conform {
1038 clauses: &[Clause {
1039 verdict: Conformance::Mandatory,
1040 when: Condition::Feature(0),
1041 }],
1042 },
1043 },
1044 Attribute {
1045 id: 0x0006,
1046 name: "WiredAssessedCurrent",
1047 kind: "uint32",
1048 access: Access::read_only(Privilege::View),
1049 qualities: AttributeQualities::NULLABLE,
1050 reporting: Reporting::ChangesOmitted,
1051 conform: Conform {
1052 clauses: &[Clause {
1053 verdict: Conformance::Optional,
1054 when: Condition::Feature(0),
1055 }],
1056 },
1057 },
1058 Attribute {
1059 id: 0x0007,
1060 name: "WiredNominalVoltage",
1061 kind: "uint32",
1062 access: Access::read_only(Privilege::View),
1063 qualities: AttributeQualities::FIXED,
1064 reporting: Reporting::OnChange,
1065 conform: Conform {
1066 clauses: &[Clause {
1067 verdict: Conformance::Optional,
1068 when: Condition::Feature(0),
1069 }],
1070 },
1071 },
1072 Attribute {
1073 id: 0x0008,
1074 name: "WiredMaximumCurrent",
1075 kind: "uint32",
1076 access: Access::read_only(Privilege::View),
1077 qualities: AttributeQualities::FIXED,
1078 reporting: Reporting::OnChange,
1079 conform: Conform {
1080 clauses: &[Clause {
1081 verdict: Conformance::Optional,
1082 when: Condition::Feature(0),
1083 }],
1084 },
1085 },
1086 Attribute {
1087 id: 0x0009,
1088 name: "WiredPresent",
1089 kind: "bool",
1090 access: Access::read_only(Privilege::View),
1091 qualities: AttributeQualities::empty(),
1092 reporting: Reporting::OnChange,
1093 conform: Conform {
1094 clauses: &[Clause {
1095 verdict: Conformance::Optional,
1096 when: Condition::Feature(0),
1097 }],
1098 },
1099 },
1100 Attribute {
1101 id: 0x000A,
1102 name: "ActiveWiredFaults",
1103 kind: "list[WiredFaultEnum]",
1104 access: Access::read_only(Privilege::View),
1105 qualities: AttributeQualities::empty(),
1106 reporting: Reporting::OnChange,
1107 conform: Conform {
1108 clauses: &[Clause {
1109 verdict: Conformance::Optional,
1110 when: Condition::Feature(0),
1111 }],
1112 },
1113 },
1114 Attribute {
1115 id: 0x000B,
1116 name: "BatVoltage",
1117 kind: "uint32",
1118 access: Access::read_only(Privilege::View),
1119 qualities: AttributeQualities::NULLABLE,
1120 reporting: Reporting::ChangesOmitted,
1121 conform: Conform {
1122 clauses: &[Clause {
1123 verdict: Conformance::Optional,
1124 when: Condition::Feature(1),
1125 }],
1126 },
1127 },
1128 Attribute {
1129 id: 0x000C,
1130 name: "BatPercentRemaining",
1131 kind: "uint8",
1132 access: Access::read_only(Privilege::View),
1133 qualities: AttributeQualities::NULLABLE,
1134 reporting: Reporting::Quieter,
1135 conform: Conform {
1136 clauses: &[Clause {
1137 verdict: Conformance::Optional,
1138 when: Condition::Feature(1),
1139 }],
1140 },
1141 },
1142 Attribute {
1143 id: 0x000D,
1144 name: "BatTimeRemaining",
1145 kind: "uint32",
1146 access: Access::read_only(Privilege::View),
1147 qualities: AttributeQualities::NULLABLE,
1148 reporting: Reporting::Quieter,
1149 conform: Conform {
1150 clauses: &[Clause {
1151 verdict: Conformance::Optional,
1152 when: Condition::Feature(1),
1153 }],
1154 },
1155 },
1156 Attribute {
1157 id: 0x000E,
1158 name: "BatChargeLevel",
1159 kind: "BatChargeLevelEnum",
1160 access: Access::read_only(Privilege::View),
1161 qualities: AttributeQualities::empty(),
1162 reporting: Reporting::OnChange,
1163 conform: Conform {
1164 clauses: &[Clause {
1165 verdict: Conformance::Mandatory,
1166 when: Condition::Feature(1),
1167 }],
1168 },
1169 },
1170 Attribute {
1171 id: 0x000F,
1172 name: "BatReplacementNeeded",
1173 kind: "bool",
1174 access: Access::read_only(Privilege::View),
1175 qualities: AttributeQualities::empty(),
1176 reporting: Reporting::OnChange,
1177 conform: Conform {
1178 clauses: &[Clause {
1179 verdict: Conformance::Mandatory,
1180 when: Condition::Feature(1),
1181 }],
1182 },
1183 },
1184 Attribute {
1185 id: 0x0010,
1186 name: "BatReplaceability",
1187 kind: "BatReplaceabilityEnum",
1188 access: Access::read_only(Privilege::View),
1189 qualities: AttributeQualities::FIXED,
1190 reporting: Reporting::OnChange,
1191 conform: Conform {
1192 clauses: &[Clause {
1193 verdict: Conformance::Mandatory,
1194 when: Condition::Feature(1),
1195 }],
1196 },
1197 },
1198 Attribute {
1199 id: 0x0011,
1200 name: "BatPresent",
1201 kind: "bool",
1202 access: Access::read_only(Privilege::View),
1203 qualities: AttributeQualities::empty(),
1204 reporting: Reporting::OnChange,
1205 conform: Conform {
1206 clauses: &[Clause {
1207 verdict: Conformance::Optional,
1208 when: Condition::Feature(1),
1209 }],
1210 },
1211 },
1212 Attribute {
1213 id: 0x0012,
1214 name: "ActiveBatFaults",
1215 kind: "list[BatFaultEnum]",
1216 access: Access::read_only(Privilege::View),
1217 qualities: AttributeQualities::empty(),
1218 reporting: Reporting::OnChange,
1219 conform: Conform {
1220 clauses: &[Clause {
1221 verdict: Conformance::Optional,
1222 when: Condition::Feature(1),
1223 }],
1224 },
1225 },
1226 Attribute {
1227 id: 0x0013,
1228 name: "BatReplacementDescription",
1229 kind: "string",
1230 access: Access::read_only(Privilege::View),
1231 qualities: AttributeQualities::FIXED,
1232 reporting: Reporting::OnChange,
1233 conform: Conform {
1234 clauses: &[Clause {
1235 verdict: Conformance::Mandatory,
1236 when: Condition::Feature(3),
1237 }],
1238 },
1239 },
1240 Attribute {
1241 id: 0x0014,
1242 name: "BatCommonDesignation",
1243 kind: "BatCommonDesignationEnum",
1244 access: Access::read_only(Privilege::View),
1245 qualities: AttributeQualities::FIXED,
1246 reporting: Reporting::OnChange,
1247 conform: Conform {
1248 clauses: &[Clause {
1249 verdict: Conformance::Optional,
1250 when: Condition::Feature(3),
1251 }],
1252 },
1253 },
1254 Attribute {
1255 id: 0x0015,
1256 name: "BatANSIDesignation",
1257 kind: "string",
1258 access: Access::read_only(Privilege::View),
1259 qualities: AttributeQualities::FIXED,
1260 reporting: Reporting::OnChange,
1261 conform: Conform {
1262 clauses: &[Clause {
1263 verdict: Conformance::Optional,
1264 when: Condition::Feature(3),
1265 }],
1266 },
1267 },
1268 Attribute {
1269 id: 0x0016,
1270 name: "BatIECDesignation",
1271 kind: "string",
1272 access: Access::read_only(Privilege::View),
1273 qualities: AttributeQualities::FIXED,
1274 reporting: Reporting::OnChange,
1275 conform: Conform {
1276 clauses: &[Clause {
1277 verdict: Conformance::Optional,
1278 when: Condition::Feature(3),
1279 }],
1280 },
1281 },
1282 Attribute {
1283 id: 0x0017,
1284 name: "BatApprovedChemistry",
1285 kind: "BatApprovedChemistryEnum",
1286 access: Access::read_only(Privilege::View),
1287 qualities: AttributeQualities::FIXED,
1288 reporting: Reporting::OnChange,
1289 conform: Conform {
1290 clauses: &[Clause {
1291 verdict: Conformance::Optional,
1292 when: Condition::Feature(3),
1293 }],
1294 },
1295 },
1296 Attribute {
1297 id: 0x0018,
1298 name: "BatCapacity",
1299 kind: "uint32",
1300 access: Access::read_only(Privilege::View),
1301 qualities: AttributeQualities::FIXED,
1302 reporting: Reporting::OnChange,
1303 conform: Conform {
1304 clauses: &[Clause {
1305 verdict: Conformance::Optional,
1306 when: Condition::Any(&[Condition::Feature(3), Condition::Feature(2)]),
1307 }],
1308 },
1309 },
1310 Attribute {
1311 id: 0x0019,
1312 name: "BatQuantity",
1313 kind: "uint8",
1314 access: Access::read_only(Privilege::View),
1315 qualities: AttributeQualities::FIXED,
1316 reporting: Reporting::OnChange,
1317 conform: Conform {
1318 clauses: &[Clause {
1319 verdict: Conformance::Mandatory,
1320 when: Condition::Feature(3),
1321 }],
1322 },
1323 },
1324 Attribute {
1325 id: 0x001A,
1326 name: "BatChargeState",
1327 kind: "BatChargeStateEnum",
1328 access: Access::read_only(Privilege::View),
1329 qualities: AttributeQualities::empty(),
1330 reporting: Reporting::OnChange,
1331 conform: Conform {
1332 clauses: &[Clause {
1333 verdict: Conformance::Mandatory,
1334 when: Condition::Feature(2),
1335 }],
1336 },
1337 },
1338 Attribute {
1339 id: 0x001B,
1340 name: "BatTimeToFullCharge",
1341 kind: "uint32",
1342 access: Access::read_only(Privilege::View),
1343 qualities: AttributeQualities::NULLABLE,
1344 reporting: Reporting::Quieter,
1345 conform: Conform {
1346 clauses: &[Clause {
1347 verdict: Conformance::Optional,
1348 when: Condition::Feature(2),
1349 }],
1350 },
1351 },
1352 Attribute {
1353 id: 0x001C,
1354 name: "BatFunctionalWhileCharging",
1355 kind: "bool",
1356 access: Access::read_only(Privilege::View),
1357 qualities: AttributeQualities::empty(),
1358 reporting: Reporting::OnChange,
1359 conform: Conform {
1360 clauses: &[Clause {
1361 verdict: Conformance::Mandatory,
1362 when: Condition::Feature(2),
1363 }],
1364 },
1365 },
1366 Attribute {
1367 id: 0x001D,
1368 name: "BatChargingCurrent",
1369 kind: "uint32",
1370 access: Access::read_only(Privilege::View),
1371 qualities: AttributeQualities::NULLABLE,
1372 reporting: Reporting::ChangesOmitted,
1373 conform: Conform {
1374 clauses: &[Clause {
1375 verdict: Conformance::Optional,
1376 when: Condition::Feature(2),
1377 }],
1378 },
1379 },
1380 Attribute {
1381 id: 0x001E,
1382 name: "ActiveBatChargeFaults",
1383 kind: "list[BatChargeFaultEnum]",
1384 access: Access::read_only(Privilege::View),
1385 qualities: AttributeQualities::empty(),
1386 reporting: Reporting::OnChange,
1387 conform: Conform {
1388 clauses: &[Clause {
1389 verdict: Conformance::Optional,
1390 when: Condition::Feature(2),
1391 }],
1392 },
1393 },
1394 Attribute {
1395 id: 0x001F,
1396 name: "EndpointList",
1397 kind: "list[endpoint-no]",
1398 access: Access::read_only(Privilege::View),
1399 qualities: AttributeQualities::empty(),
1400 reporting: Reporting::OnChange,
1401 conform: Conform::MANDATORY,
1402 },
1403];
1404
1405pub const COMMANDS: &[Command] = &[];
1407
1408pub const EVENTS: &[Event] = &[
1410 Event {
1411 id: 0x00,
1412 name: "WiredFaultChange",
1413 priority: EventPriority::Info,
1414 access: Access::read_only(Privilege::View),
1415 conform: Conform {
1416 clauses: &[Clause {
1417 verdict: Conformance::Optional,
1418 when: Condition::Feature(0),
1419 }],
1420 },
1421 },
1422 Event {
1423 id: 0x01,
1424 name: "BatFaultChange",
1425 priority: EventPriority::Info,
1426 access: Access::read_only(Privilege::View),
1427 conform: Conform {
1428 clauses: &[Clause {
1429 verdict: Conformance::Optional,
1430 when: Condition::Feature(1),
1431 }],
1432 },
1433 },
1434 Event {
1435 id: 0x02,
1436 name: "BatChargeFaultChange",
1437 priority: EventPriority::Info,
1438 access: Access::read_only(Privilege::View),
1439 conform: Conform {
1440 clauses: &[Clause {
1441 verdict: Conformance::Optional,
1442 when: Condition::Feature(2),
1443 }],
1444 },
1445 },
1446];
1447
1448pub const CLUSTER: Cluster = Cluster {
1450 id: ID,
1451 name: "Power Source",
1452 revision: REVISION,
1453 pics: "PS",
1454 derived_from: None,
1455 features: FEATURES,
1456 attributes: ATTRIBUTES,
1457 commands: COMMANDS,
1458 events: EVENTS,
1459};