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 = 0x0099;
28
29pub const REVISION: u16 = 4;
32
33pub const PICS: &str = "EEVSE";
35
36pub mod feature {
41 pub const CHARGING_PREFERENCES: u32 = 1 << 0;
45 pub const SO_C_REPORTING: u32 = 1 << 1;
49 pub const PLUG_AND_CHARGE: u32 = 1 << 2;
53 pub const RFID: u32 = 1 << 3;
57 pub const V2_X: u32 = 1 << 4;
61}
62
63pub const FEATURES: &[Feature] = &[
65 Feature {
66 bit: 0,
67 code: "PREF",
68 name: "ChargingPreferences",
69 conform: Conform::MANDATORY,
70 },
71 Feature {
72 bit: 1,
73 code: "SOC",
74 name: "SoCReporting",
75 conform: Conform::OPTIONAL,
76 },
77 Feature {
78 bit: 2,
79 code: "PNC",
80 name: "PlugAndCharge",
81 conform: Conform::OPTIONAL,
82 },
83 Feature {
84 bit: 3,
85 code: "RFID",
86 name: "RFID",
87 conform: Conform::OPTIONAL,
88 },
89 Feature {
90 bit: 4,
91 code: "V2X",
92 name: "V2X",
93 conform: Conform::OPTIONAL,
94 },
95];
96
97pub mod attribute {
99 use crate::im::AttributeId;
100
101 pub const STATE: AttributeId = 0x00;
103 pub const SUPPLY_STATE: AttributeId = 0x01;
105 pub const FAULT_STATE: AttributeId = 0x02;
107 pub const CHARGING_ENABLED_UNTIL: AttributeId = 0x03;
109 pub const DISCHARGING_ENABLED_UNTIL: AttributeId = 0x04;
111 pub const CIRCUIT_CAPACITY: AttributeId = 0x05;
113 pub const MINIMUM_CHARGE_CURRENT: AttributeId = 0x06;
115 pub const MAXIMUM_CHARGE_CURRENT: AttributeId = 0x07;
117 pub const MAXIMUM_DISCHARGE_CURRENT: AttributeId = 0x08;
119 pub const USER_MAXIMUM_CHARGE_CURRENT: AttributeId = 0x09;
121 pub const RANDOMIZATION_DELAY_WINDOW: AttributeId = 0x0A;
123 pub const NEXT_CHARGE_START_TIME: AttributeId = 0x23;
125 pub const NEXT_CHARGE_TARGET_TIME: AttributeId = 0x24;
127 pub const NEXT_CHARGE_REQUIRED_ENERGY: AttributeId = 0x25;
129 pub const NEXT_CHARGE_TARGET_SO_C: AttributeId = 0x26;
131 pub const APPROXIMATE_EV_EFFICIENCY: AttributeId = 0x27;
133 pub const STATE_OF_CHARGE: AttributeId = 0x30;
135 pub const BATTERY_CAPACITY: AttributeId = 0x31;
137 pub const VEHICLE_ID: AttributeId = 0x32;
139 pub const SESSION_ID: AttributeId = 0x40;
141 pub const SESSION_DURATION: AttributeId = 0x41;
143 pub const SESSION_ENERGY_CHARGED: AttributeId = 0x42;
145 pub const SESSION_ENERGY_DISCHARGED: AttributeId = 0x43;
147}
148
149pub mod command {
151 use crate::im::CommandId;
152
153 pub const GET_TARGETS_RESPONSE: CommandId = 0x00;
155 pub const DISABLE: CommandId = 0x01;
157 pub const ENABLE_CHARGING: CommandId = 0x02;
159 pub const ENABLE_DISCHARGING: CommandId = 0x03;
161 pub const START_DIAGNOSTICS: CommandId = 0x04;
163 pub const SET_TARGETS: CommandId = 0x05;
165 pub const GET_TARGETS: CommandId = 0x06;
167 pub const CLEAR_TARGETS: CommandId = 0x07;
169}
170
171pub mod event {
173 use crate::im::EventId;
174
175 pub const EV_CONNECTED: EventId = 0x00;
177 pub const EV_NOT_DETECTED: EventId = 0x01;
179 pub const ENERGY_TRANSFER_STARTED: EventId = 0x02;
181 pub const ENERGY_TRANSFER_STOPPED: EventId = 0x03;
183 pub const FAULT: EventId = 0x04;
185 pub const RFID: EventId = 0x05;
187}
188
189#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
191#[repr(u8)]
192pub enum EnergyTransferStoppedReasonEnum {
193 EVStopped = 0,
195 EVSEStopped = 1,
197 Other = 2,
199}
200
201impl EnergyTransferStoppedReasonEnum {
202 #[must_use]
204 pub const fn from_value(value: u8) -> Option<Self> {
205 match value {
206 0 => Some(Self::EVStopped),
207 1 => Some(Self::EVSEStopped),
208 2 => Some(Self::Other),
209 _ => None,
210 }
211 }
212
213 #[must_use]
215 pub const fn value(self) -> u8 {
216 self as u8
217 }
218}
219
220impl ToTlv for EnergyTransferStoppedReasonEnum {
221 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
222 self.value().to_tlv(w, tag)
223 }
224}
225
226impl<'a> FromTlv<'a> for EnergyTransferStoppedReasonEnum {
227 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
228 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
229 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
230 }
231}
232
233#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
235#[repr(u8)]
236pub enum FaultStateEnum {
237 NoError = 0,
239 MeterFailure = 1,
241 OverVoltage = 2,
243 UnderVoltage = 3,
245 OverCurrent = 4,
247 ContactWetFailure = 5,
249 ContactDryFailure = 6,
251 GroundFault = 7,
253 PowerLoss = 8,
255 PowerQuality = 9,
257 PilotShortCircuit = 10,
259 EmergencyStop = 11,
261 EVDisconnected = 12,
263 WrongPowerSupply = 13,
265 LiveNeutralSwap = 14,
267 OverTemperature = 15,
269 Other = 255,
271}
272
273impl FaultStateEnum {
274 #[must_use]
276 pub const fn from_value(value: u8) -> Option<Self> {
277 match value {
278 0 => Some(Self::NoError),
279 1 => Some(Self::MeterFailure),
280 2 => Some(Self::OverVoltage),
281 3 => Some(Self::UnderVoltage),
282 4 => Some(Self::OverCurrent),
283 5 => Some(Self::ContactWetFailure),
284 6 => Some(Self::ContactDryFailure),
285 7 => Some(Self::GroundFault),
286 8 => Some(Self::PowerLoss),
287 9 => Some(Self::PowerQuality),
288 10 => Some(Self::PilotShortCircuit),
289 11 => Some(Self::EmergencyStop),
290 12 => Some(Self::EVDisconnected),
291 13 => Some(Self::WrongPowerSupply),
292 14 => Some(Self::LiveNeutralSwap),
293 15 => Some(Self::OverTemperature),
294 255 => Some(Self::Other),
295 _ => None,
296 }
297 }
298
299 #[must_use]
301 pub const fn value(self) -> u8 {
302 self as u8
303 }
304}
305
306impl ToTlv for FaultStateEnum {
307 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
308 self.value().to_tlv(w, tag)
309 }
310}
311
312impl<'a> FromTlv<'a> for FaultStateEnum {
313 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
314 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
315 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
316 }
317}
318
319#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
321#[repr(u8)]
322pub enum StateEnum {
323 NotPluggedIn = 0,
325 PluggedInNoDemand = 1,
327 PluggedInDemand = 2,
329 PluggedInCharging = 3,
331 PluggedInDischarging = 4,
333 SessionEnding = 5,
335 Fault = 6,
337}
338
339impl StateEnum {
340 #[must_use]
342 pub const fn from_value(value: u8) -> Option<Self> {
343 match value {
344 0 => Some(Self::NotPluggedIn),
345 1 => Some(Self::PluggedInNoDemand),
346 2 => Some(Self::PluggedInDemand),
347 3 => Some(Self::PluggedInCharging),
348 4 => Some(Self::PluggedInDischarging),
349 5 => Some(Self::SessionEnding),
350 6 => Some(Self::Fault),
351 _ => None,
352 }
353 }
354
355 #[must_use]
357 pub const fn value(self) -> u8 {
358 self as u8
359 }
360}
361
362impl ToTlv for StateEnum {
363 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
364 self.value().to_tlv(w, tag)
365 }
366}
367
368impl<'a> FromTlv<'a> for StateEnum {
369 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
370 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
371 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
372 }
373}
374
375#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
377#[repr(u8)]
378pub enum SupplyStateEnum {
379 Disabled = 0,
381 ChargingEnabled = 1,
383 DischargingEnabled = 2,
385 DisabledError = 3,
387 DisabledDiagnostics = 4,
389 Enabled = 5,
391}
392
393impl SupplyStateEnum {
394 #[must_use]
396 pub const fn from_value(value: u8) -> Option<Self> {
397 match value {
398 0 => Some(Self::Disabled),
399 1 => Some(Self::ChargingEnabled),
400 2 => Some(Self::DischargingEnabled),
401 3 => Some(Self::DisabledError),
402 4 => Some(Self::DisabledDiagnostics),
403 5 => Some(Self::Enabled),
404 _ => None,
405 }
406 }
407
408 #[must_use]
410 pub const fn value(self) -> u8 {
411 self as u8
412 }
413}
414
415impl ToTlv for SupplyStateEnum {
416 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
417 self.value().to_tlv(w, tag)
418 }
419}
420
421impl<'a> FromTlv<'a> for SupplyStateEnum {
422 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
423 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
424 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
425 }
426}
427
428bitflags::bitflags! {
429 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
431 pub struct TargetDayOfWeekBitmap: u8 {
432 const SUNDAY = 1 << 0;
434 const MONDAY = 1 << 1;
436 const TUESDAY = 1 << 2;
438 const WEDNESDAY = 1 << 3;
440 const THURSDAY = 1 << 4;
442 const FRIDAY = 1 << 5;
444 const SATURDAY = 1 << 6;
446 }
447}
448
449impl ToTlv for TargetDayOfWeekBitmap {
450 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
451 self.bits().to_tlv(w, tag)
452 }
453}
454
455impl<'a> FromTlv<'a> for TargetDayOfWeekBitmap {
456 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
457 let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
458 Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
459 }
460}
461
462#[derive(Debug, Clone, Copy, PartialEq)]
464pub struct ChargingTargetScheduleStruct<'a> {
465 pub day_of_week_for_sequence: TargetDayOfWeekBitmap,
467 pub charging_targets: TlvList<'a, ChargingTargetStruct>,
469}
470
471impl<'a> ToTlv for ChargingTargetScheduleStruct<'a> {
472 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
473 w.start_structure(tag)?;
474 self.day_of_week_for_sequence.to_tlv(w, Tag::Context(0))?;
475 self.charging_targets.to_tlv(w, Tag::Context(1))?;
476 w.end_container()
477 }
478}
479
480impl<'a> FromTlv<'a> for ChargingTargetScheduleStruct<'a> {
481 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
482 if element.value.container() != Some(ContainerKind::Structure) {
483 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
484 }
485 let mut day_of_week_for_sequence = None;
486 let mut charging_targets = None;
487 loop {
488 let Some(field) = reader.next_element()? else {
489 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
490 };
491 if field.value == Value::EndOfContainer {
492 break;
493 }
494 match field.tag.context() {
495 Some(0) => {
496 day_of_week_for_sequence =
497 Some(<TargetDayOfWeekBitmap>::from_tlv(reader, &field)?)
498 }
499 Some(1) => {
500 charging_targets = Some(<TlvList<'a, ChargingTargetStruct>>::from_tlv(
501 reader, &field,
502 )?)
503 }
504 _ => reader.skip_value(&field)?,
508 }
509 }
510 Ok(Self {
511 day_of_week_for_sequence: day_of_week_for_sequence
512 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
513 charging_targets: charging_targets
514 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
515 })
516 }
517}
518
519#[derive(Debug, Clone, Copy, PartialEq)]
521pub struct ChargingTargetStruct {
522 pub target_time_minutes_past_midnight: u16,
524 pub target_so_c: Option<u8>,
526 pub added_energy: Option<i64>,
528}
529
530impl ToTlv for ChargingTargetStruct {
531 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
532 w.start_structure(tag)?;
533 self.target_time_minutes_past_midnight
534 .to_tlv(w, Tag::Context(0))?;
535 if let Some(value) = &self.target_so_c {
536 value.to_tlv(w, Tag::Context(1))?;
537 }
538 if let Some(value) = &self.added_energy {
539 value.to_tlv(w, Tag::Context(2))?;
540 }
541 w.end_container()
542 }
543}
544
545impl<'a> FromTlv<'a> for ChargingTargetStruct {
546 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
547 if element.value.container() != Some(ContainerKind::Structure) {
548 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
549 }
550 let mut target_time_minutes_past_midnight = None;
551 let mut target_so_c = None;
552 let mut added_energy = None;
553 loop {
554 let Some(field) = reader.next_element()? else {
555 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
556 };
557 if field.value == Value::EndOfContainer {
558 break;
559 }
560 match field.tag.context() {
561 Some(0) => {
562 target_time_minutes_past_midnight = Some(<u16>::from_tlv(reader, &field)?)
563 }
564 Some(1) => target_so_c = Some(<u8>::from_tlv(reader, &field)?),
565 Some(2) => added_energy = Some(<i64>::from_tlv(reader, &field)?),
566 _ => reader.skip_value(&field)?,
570 }
571 }
572 Ok(Self {
573 target_time_minutes_past_midnight: target_time_minutes_past_midnight
574 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
575 target_so_c,
576 added_energy,
577 })
578 }
579}
580
581#[derive(Debug, Clone, Copy, PartialEq)]
583pub struct GetTargetsResponseFields<'a> {
584 pub charging_target_schedules: TlvList<'a, ChargingTargetScheduleStruct<'a>>,
586}
587
588impl<'a> ToTlv for GetTargetsResponseFields<'a> {
589 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
590 w.start_structure(tag)?;
591 self.charging_target_schedules.to_tlv(w, Tag::Context(0))?;
592 w.end_container()
593 }
594}
595
596impl<'a> FromTlv<'a> for GetTargetsResponseFields<'a> {
597 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
598 if element.value.container() != Some(ContainerKind::Structure) {
599 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
600 }
601 let mut charging_target_schedules = None;
602 loop {
603 let Some(field) = reader.next_element()? else {
604 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
605 };
606 if field.value == Value::EndOfContainer {
607 break;
608 }
609 match field.tag.context() {
610 Some(0) => {
611 charging_target_schedules = Some(
612 <TlvList<'a, ChargingTargetScheduleStruct<'a>>>::from_tlv(reader, &field)?,
613 )
614 }
615 _ => reader.skip_value(&field)?,
619 }
620 }
621 Ok(Self {
622 charging_target_schedules: charging_target_schedules
623 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
624 })
625 }
626}
627
628#[derive(Debug, Clone, Copy, PartialEq)]
630pub struct EnableChargingFields {
631 pub charging_enabled_until: Nullable<u32>,
633 pub minimum_charge_current: i32,
635 pub maximum_charge_current: i32,
637}
638
639impl ToTlv for EnableChargingFields {
640 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
641 w.start_structure(tag)?;
642 self.charging_enabled_until.to_tlv(w, Tag::Context(0))?;
643 self.minimum_charge_current.to_tlv(w, Tag::Context(1))?;
644 self.maximum_charge_current.to_tlv(w, Tag::Context(2))?;
645 w.end_container()
646 }
647}
648
649impl<'a> FromTlv<'a> for EnableChargingFields {
650 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
651 if element.value.container() != Some(ContainerKind::Structure) {
652 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
653 }
654 let mut charging_enabled_until = None;
655 let mut minimum_charge_current = None;
656 let mut maximum_charge_current = None;
657 loop {
658 let Some(field) = reader.next_element()? else {
659 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
660 };
661 if field.value == Value::EndOfContainer {
662 break;
663 }
664 match field.tag.context() {
665 Some(0) => {
666 charging_enabled_until = Some(<Nullable<u32>>::from_tlv(reader, &field)?)
667 }
668 Some(1) => minimum_charge_current = Some(<i32>::from_tlv(reader, &field)?),
669 Some(2) => maximum_charge_current = Some(<i32>::from_tlv(reader, &field)?),
670 _ => reader.skip_value(&field)?,
674 }
675 }
676 Ok(Self {
677 charging_enabled_until: charging_enabled_until
678 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
679 minimum_charge_current: minimum_charge_current
680 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
681 maximum_charge_current: maximum_charge_current
682 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
683 })
684 }
685}
686
687#[derive(Debug, Clone, Copy, PartialEq)]
689pub struct EnableDischargingFields {
690 pub discharging_enabled_until: Nullable<u32>,
692 pub maximum_discharge_current: i32,
694}
695
696impl ToTlv for EnableDischargingFields {
697 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
698 w.start_structure(tag)?;
699 self.discharging_enabled_until.to_tlv(w, Tag::Context(0))?;
700 self.maximum_discharge_current.to_tlv(w, Tag::Context(1))?;
701 w.end_container()
702 }
703}
704
705impl<'a> FromTlv<'a> for EnableDischargingFields {
706 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
707 if element.value.container() != Some(ContainerKind::Structure) {
708 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
709 }
710 let mut discharging_enabled_until = None;
711 let mut maximum_discharge_current = None;
712 loop {
713 let Some(field) = reader.next_element()? else {
714 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
715 };
716 if field.value == Value::EndOfContainer {
717 break;
718 }
719 match field.tag.context() {
720 Some(0) => {
721 discharging_enabled_until = Some(<Nullable<u32>>::from_tlv(reader, &field)?)
722 }
723 Some(1) => maximum_discharge_current = Some(<i32>::from_tlv(reader, &field)?),
724 _ => reader.skip_value(&field)?,
728 }
729 }
730 Ok(Self {
731 discharging_enabled_until: discharging_enabled_until
732 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
733 maximum_discharge_current: maximum_discharge_current
734 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
735 })
736 }
737}
738
739#[derive(Debug, Clone, Copy, PartialEq)]
741pub struct SetTargetsFields<'a> {
742 pub charging_target_schedules: TlvList<'a, ChargingTargetScheduleStruct<'a>>,
744}
745
746impl<'a> ToTlv for SetTargetsFields<'a> {
747 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
748 w.start_structure(tag)?;
749 self.charging_target_schedules.to_tlv(w, Tag::Context(0))?;
750 w.end_container()
751 }
752}
753
754impl<'a> FromTlv<'a> for SetTargetsFields<'a> {
755 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
756 if element.value.container() != Some(ContainerKind::Structure) {
757 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
758 }
759 let mut charging_target_schedules = None;
760 loop {
761 let Some(field) = reader.next_element()? else {
762 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
763 };
764 if field.value == Value::EndOfContainer {
765 break;
766 }
767 match field.tag.context() {
768 Some(0) => {
769 charging_target_schedules = Some(
770 <TlvList<'a, ChargingTargetScheduleStruct<'a>>>::from_tlv(reader, &field)?,
771 )
772 }
773 _ => reader.skip_value(&field)?,
777 }
778 }
779 Ok(Self {
780 charging_target_schedules: charging_target_schedules
781 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
782 })
783 }
784}
785
786pub const ATTRIBUTES: &[Attribute] = &[
788 Attribute {
789 id: 0x0000,
790 name: "State",
791 kind: "StateEnum",
792 access: Access::read_only(Privilege::View),
793 qualities: AttributeQualities::NULLABLE,
794 reporting: Reporting::OnChange,
795 conform: Conform::MANDATORY,
796 },
797 Attribute {
798 id: 0x0001,
799 name: "SupplyState",
800 kind: "SupplyStateEnum",
801 access: Access::read_only(Privilege::View),
802 qualities: AttributeQualities::empty(),
803 reporting: Reporting::OnChange,
804 conform: Conform::MANDATORY,
805 },
806 Attribute {
807 id: 0x0002,
808 name: "FaultState",
809 kind: "FaultStateEnum",
810 access: Access::read_only(Privilege::View),
811 qualities: AttributeQualities::empty(),
812 reporting: Reporting::OnChange,
813 conform: Conform::MANDATORY,
814 },
815 Attribute {
816 id: 0x0003,
817 name: "ChargingEnabledUntil",
818 kind: "epoch-s",
819 access: Access::read_only(Privilege::View),
820 qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
821 reporting: Reporting::OnChange,
822 conform: Conform::MANDATORY,
823 },
824 Attribute {
825 id: 0x0004,
826 name: "DischargingEnabledUntil",
827 kind: "epoch-s",
828 access: Access::read_only(Privilege::View),
829 qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
830 reporting: Reporting::OnChange,
831 conform: Conform {
832 clauses: &[Clause {
833 verdict: Conformance::Mandatory,
834 when: Condition::Feature(4),
835 }],
836 },
837 },
838 Attribute {
839 id: 0x0005,
840 name: "CircuitCapacity",
841 kind: "amperage-mA",
842 access: Access::read_only(Privilege::View),
843 qualities: AttributeQualities::NON_VOLATILE,
844 reporting: Reporting::OnChange,
845 conform: Conform::MANDATORY,
846 },
847 Attribute {
848 id: 0x0006,
849 name: "MinimumChargeCurrent",
850 kind: "amperage-mA",
851 access: Access::read_only(Privilege::View),
852 qualities: AttributeQualities::NON_VOLATILE,
853 reporting: Reporting::OnChange,
854 conform: Conform::MANDATORY,
855 },
856 Attribute {
857 id: 0x0007,
858 name: "MaximumChargeCurrent",
859 kind: "amperage-mA",
860 access: Access::read_only(Privilege::View),
861 qualities: AttributeQualities::NON_VOLATILE,
862 reporting: Reporting::OnChange,
863 conform: Conform::MANDATORY,
864 },
865 Attribute {
866 id: 0x0008,
867 name: "MaximumDischargeCurrent",
868 kind: "amperage-mA",
869 access: Access::read_only(Privilege::View),
870 qualities: AttributeQualities::NON_VOLATILE,
871 reporting: Reporting::OnChange,
872 conform: Conform {
873 clauses: &[Clause {
874 verdict: Conformance::Mandatory,
875 when: Condition::Feature(4),
876 }],
877 },
878 },
879 Attribute {
880 id: 0x0009,
881 name: "UserMaximumChargeCurrent",
882 kind: "amperage-mA",
883 access: Access::read_write_with(Privilege::View, Privilege::Manage),
884 qualities: AttributeQualities::NON_VOLATILE,
885 reporting: Reporting::OnChange,
886 conform: Conform::OPTIONAL,
887 },
888 Attribute {
889 id: 0x000A,
890 name: "RandomizationDelayWindow",
891 kind: "elapsed-s",
892 access: Access::read_write_with(Privilege::View, Privilege::Manage),
893 qualities: AttributeQualities::NON_VOLATILE,
894 reporting: Reporting::OnChange,
895 conform: Conform::OPTIONAL,
896 },
897 Attribute {
898 id: 0x0023,
899 name: "NextChargeStartTime",
900 kind: "epoch-s",
901 access: Access::read_only(Privilege::View),
902 qualities: AttributeQualities::NULLABLE,
903 reporting: Reporting::OnChange,
904 conform: Conform {
905 clauses: &[Clause {
906 verdict: Conformance::Mandatory,
907 when: Condition::Feature(0),
908 }],
909 },
910 },
911 Attribute {
912 id: 0x0024,
913 name: "NextChargeTargetTime",
914 kind: "epoch-s",
915 access: Access::read_only(Privilege::View),
916 qualities: AttributeQualities::NULLABLE,
917 reporting: Reporting::OnChange,
918 conform: Conform {
919 clauses: &[Clause {
920 verdict: Conformance::Mandatory,
921 when: Condition::Feature(0),
922 }],
923 },
924 },
925 Attribute {
926 id: 0x0025,
927 name: "NextChargeRequiredEnergy",
928 kind: "energy-mWh",
929 access: Access::read_only(Privilege::View),
930 qualities: AttributeQualities::NULLABLE,
931 reporting: Reporting::OnChange,
932 conform: Conform {
933 clauses: &[Clause {
934 verdict: Conformance::Mandatory,
935 when: Condition::Feature(0),
936 }],
937 },
938 },
939 Attribute {
940 id: 0x0026,
941 name: "NextChargeTargetSoC",
942 kind: "percent",
943 access: Access::read_only(Privilege::View),
944 qualities: AttributeQualities::NULLABLE,
945 reporting: Reporting::OnChange,
946 conform: Conform {
947 clauses: &[Clause {
948 verdict: Conformance::Mandatory,
949 when: Condition::Feature(0),
950 }],
951 },
952 },
953 Attribute {
954 id: 0x0027,
955 name: "ApproximateEVEfficiency",
956 kind: "uint16",
957 access: Access::read_write_with(Privilege::View, Privilege::Manage),
958 qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
959 reporting: Reporting::OnChange,
960 conform: Conform {
961 clauses: &[Clause {
962 verdict: Conformance::Optional,
963 when: Condition::Feature(0),
964 }],
965 },
966 },
967 Attribute {
968 id: 0x0030,
969 name: "StateOfCharge",
970 kind: "percent",
971 access: Access::read_only(Privilege::View),
972 qualities: AttributeQualities::NULLABLE,
973 reporting: Reporting::OnChange,
974 conform: Conform {
975 clauses: &[Clause {
976 verdict: Conformance::Mandatory,
977 when: Condition::Feature(1),
978 }],
979 },
980 },
981 Attribute {
982 id: 0x0031,
983 name: "BatteryCapacity",
984 kind: "energy-mWh",
985 access: Access::read_only(Privilege::View),
986 qualities: AttributeQualities::NULLABLE,
987 reporting: Reporting::OnChange,
988 conform: Conform {
989 clauses: &[Clause {
990 verdict: Conformance::Mandatory,
991 when: Condition::Feature(1),
992 }],
993 },
994 },
995 Attribute {
996 id: 0x0032,
997 name: "VehicleID",
998 kind: "string",
999 access: Access::read_only(Privilege::View),
1000 qualities: AttributeQualities::NULLABLE,
1001 reporting: Reporting::OnChange,
1002 conform: Conform {
1003 clauses: &[Clause {
1004 verdict: Conformance::Mandatory,
1005 when: Condition::Feature(2),
1006 }],
1007 },
1008 },
1009 Attribute {
1010 id: 0x0040,
1011 name: "SessionID",
1012 kind: "uint32",
1013 access: Access::read_only(Privilege::View),
1014 qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
1015 reporting: Reporting::OnChange,
1016 conform: Conform::MANDATORY,
1017 },
1018 Attribute {
1019 id: 0x0041,
1020 name: "SessionDuration",
1021 kind: "elapsed-s",
1022 access: Access::read_only(Privilege::View),
1023 qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
1024 reporting: Reporting::Quieter,
1025 conform: Conform::MANDATORY,
1026 },
1027 Attribute {
1028 id: 0x0042,
1029 name: "SessionEnergyCharged",
1030 kind: "energy-mWh",
1031 access: Access::read_only(Privilege::View),
1032 qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
1033 reporting: Reporting::Quieter,
1034 conform: Conform::MANDATORY,
1035 },
1036 Attribute {
1037 id: 0x0043,
1038 name: "SessionEnergyDischarged",
1039 kind: "energy-mWh",
1040 access: Access::read_only(Privilege::View),
1041 qualities: AttributeQualities::NULLABLE.union(AttributeQualities::NON_VOLATILE),
1042 reporting: Reporting::Quieter,
1043 conform: Conform {
1044 clauses: &[Clause {
1045 verdict: Conformance::Mandatory,
1046 when: Condition::Feature(4),
1047 }],
1048 },
1049 },
1050];
1051
1052pub const COMMANDS: &[Command] = &[
1054 Command {
1055 id: 0x00,
1056 name: "GetTargetsResponse",
1057 to_server: false,
1058 response: None,
1059 access: Access::invoke(Privilege::Operate),
1060 conform: Conform {
1061 clauses: &[Clause {
1062 verdict: Conformance::Mandatory,
1063 when: Condition::Feature(0),
1064 }],
1065 },
1066 },
1067 Command {
1068 id: 0x01,
1069 name: "Disable",
1070 to_server: true,
1071 response: None,
1072 access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
1073 conform: Conform::MANDATORY,
1074 },
1075 Command {
1076 id: 0x02,
1077 name: "EnableCharging",
1078 to_server: true,
1079 response: None,
1080 access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
1081 conform: Conform::MANDATORY,
1082 },
1083 Command {
1084 id: 0x03,
1085 name: "EnableDischarging",
1086 to_server: true,
1087 response: None,
1088 access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
1089 conform: Conform {
1090 clauses: &[Clause {
1091 verdict: Conformance::Mandatory,
1092 when: Condition::Feature(4),
1093 }],
1094 },
1095 },
1096 Command {
1097 id: 0x04,
1098 name: "StartDiagnostics",
1099 to_server: true,
1100 response: None,
1101 access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
1102 conform: Conform::OPTIONAL,
1103 },
1104 Command {
1105 id: 0x05,
1106 name: "SetTargets",
1107 to_server: true,
1108 response: None,
1109 access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
1110 conform: Conform {
1111 clauses: &[Clause {
1112 verdict: Conformance::Mandatory,
1113 when: Condition::Feature(0),
1114 }],
1115 },
1116 },
1117 Command {
1118 id: 0x06,
1119 name: "GetTargets",
1120 to_server: true,
1121 response: Some(0x00),
1122 access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
1123 conform: Conform {
1124 clauses: &[Clause {
1125 verdict: Conformance::Mandatory,
1126 when: Condition::Feature(0),
1127 }],
1128 },
1129 },
1130 Command {
1131 id: 0x07,
1132 name: "ClearTargets",
1133 to_server: true,
1134 response: None,
1135 access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::TIMED),
1136 conform: Conform {
1137 clauses: &[Clause {
1138 verdict: Conformance::Mandatory,
1139 when: Condition::Feature(0),
1140 }],
1141 },
1142 },
1143];
1144
1145pub const EVENTS: &[Event] = &[
1147 Event {
1148 id: 0x00,
1149 name: "EVConnected",
1150 priority: EventPriority::Info,
1151 access: Access::read_only(Privilege::View),
1152 conform: Conform::MANDATORY,
1153 },
1154 Event {
1155 id: 0x01,
1156 name: "EVNotDetected",
1157 priority: EventPriority::Info,
1158 access: Access::read_only(Privilege::View),
1159 conform: Conform::MANDATORY,
1160 },
1161 Event {
1162 id: 0x02,
1163 name: "EnergyTransferStarted",
1164 priority: EventPriority::Info,
1165 access: Access::read_only(Privilege::View),
1166 conform: Conform::MANDATORY,
1167 },
1168 Event {
1169 id: 0x03,
1170 name: "EnergyTransferStopped",
1171 priority: EventPriority::Info,
1172 access: Access::read_only(Privilege::View),
1173 conform: Conform::MANDATORY,
1174 },
1175 Event {
1176 id: 0x04,
1177 name: "Fault",
1178 priority: EventPriority::Critical,
1179 access: Access::read_only(Privilege::View),
1180 conform: Conform::MANDATORY,
1181 },
1182 Event {
1183 id: 0x05,
1184 name: "RFID",
1185 priority: EventPriority::Info,
1186 access: Access::read_only(Privilege::View),
1187 conform: Conform {
1188 clauses: &[Clause {
1189 verdict: Conformance::Optional,
1190 when: Condition::Feature(3),
1191 }],
1192 },
1193 },
1194];
1195
1196pub const CLUSTER: Cluster = Cluster {
1198 id: ID,
1199 name: "Energy EVSE",
1200 revision: REVISION,
1201 pics: "EEVSE",
1202 derived_from: None,
1203 features: FEATURES,
1204 attributes: ATTRIBUTES,
1205 commands: COMMANDS,
1206 events: EVENTS,
1207};