From c5799902c107582d61ed6f6155299739f2103400 Mon Sep 17 00:00:00 2001 From: Maxime Augier Date: Fri, 2 Aug 2024 13:50:06 +0200 Subject: [PATCH] Add some enums for decoding integer values --- src/api.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/api.rs b/src/api.rs index cdd4e24..051dad5 100644 --- a/src/api.rs +++ b/src/api.rs @@ -8,7 +8,7 @@ use tracing::{debug, info, instrument}; /// API Authentication context #[derive(Debug)] pub struct Context { - auth_header: String, + auth_header: String, //TODO mark as secret to hide in tracing refresh_token: String, token_expiration: Instant, } @@ -60,11 +60,27 @@ pub struct Charger { #[derive(Clone,Copy,Debug,Deserialize_repr,Eq,Ord,PartialEq,PartialOrd)] #[repr(u8)] pub enum ChargerOpMode { - Zero = 0, - One = 1, + Disconnected = 1, Paused = 2, Charging = 3, Finished = 4, + Error = 5, + Ready = 6, +} + +#[derive(Clone,Copy,Debug,Deserialize_repr,Eq,Ord,PartialEq,PartialOrd)] +#[repr(u8)] +pub enum OutputPhase { + L1ToN = 10, + L2ToN = 12, + L3ToN = 14, + L1ToL2 = 11, + L2ToL3 = 15, + L3ToL1 = 13, + L1L2ToN = 20, + L2L3ToN = 21, + L1L3ToL2 = 22, + L1L2L3ToN = 30, } #[derive(Clone,Debug,Deserialize,PartialEq,PartialOrd)] @@ -85,7 +101,7 @@ pub struct ChargerState { #[serde(rename="localRSSI")] pub local_rssi: Option, - pub output_phase: u32, + pub output_phase: OutputPhase, pub dynamic_circuit_current_p1: u32, pub dynamic_circuit_current_p2: u32, pub dynamic_circuit_current_p3: u32,