use core::fmt; use num_enum::{IntoPrimitive, TryFromPrimitive}; /// Message Identifier used in the communication protocol. This is specified by Viessmann /// and UNACKED is rarely to never used. #[repr(u8)] #[derive(Debug, TryFromPrimitive, IntoPrimitive, Clone, Copy, PartialEq, Eq)] pub enum MessageIdentifier { Request = 0x00, Response = 0x01, Unacked = 0x02, CommError = 0x03, } impl fmt::Display for MessageIdentifier { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Self::Request => write!(f, "Request"), Self::Response => write!(f, "Response"), Self::Unacked => write!(f, "Unacked"), Self::CommError => write!(f, "CommError"), } } } /// Function Code used in the communication protocol. /// /// This is specified by Viessmann and Read and Write are usually used for simpler values, /// RPC can maybe be used for more complex things, but this is currently unclear #[repr(u8)] #[derive(Debug, TryFromPrimitive, IntoPrimitive, Clone, Copy, PartialEq, Eq)] pub enum FunctionCode { VirtualREAD = 0x01, VirtualWRITE = 0x02, RemoteProcedureCall = 0x07, } impl fmt::Display for FunctionCode { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Self::VirtualREAD => write!(f, "VirtualREAD"), Self::VirtualWRITE => write!(f, "VirtualWRITE"), Self::RemoteProcedureCall => write!(f, "RemoteProcedureCall"), } } } /// Response code used in the communication protocol. This is specified by Viessmann #[repr(u8)] #[derive(Debug, TryFromPrimitive)] pub enum ResponseCode { Ack = 0x06, Nack = 0x15, Enq = 0x05, }