1#[derive(Copy, Clone, Eq, PartialEq, Debug)]
2#[cfg_attr(feature = "defmt", derive(defmt::Format))]
3#[repr(u8)]
4pub enum RequestCommandClass {
5 DiscoveryCommand = 0x10,
6 GetCommand = 0x20,
7 SetCommand = 0x30,
8}
9
10#[derive(Copy, Clone, Eq, PartialEq, Debug)]
11#[cfg_attr(feature = "defmt", derive(defmt::Format))]
12#[repr(u8)]
13pub enum ResponseCommandClass {
14 DiscoveryCommandResponse = 0x11,
15 GetCommandResponse = 0x21,
16 SetCommandResponse = 0x31,
17}
18
19impl RequestCommandClass {
20 pub fn get_response_class(&self) -> ResponseCommandClass {
22 match self {
23 Self::DiscoveryCommand => ResponseCommandClass::DiscoveryCommandResponse,
24 Self::GetCommand => ResponseCommandClass::GetCommandResponse,
25 Self::SetCommand => ResponseCommandClass::SetCommandResponse,
26 }
27 }
28}
29
30impl ResponseCommandClass {
31 pub fn get_request_class(&self) -> RequestCommandClass {
33 match self {
34 Self::DiscoveryCommandResponse => RequestCommandClass::DiscoveryCommand,
35 Self::GetCommandResponse => RequestCommandClass::GetCommand,
36 Self::SetCommandResponse => RequestCommandClass::SetCommand,
37 }
38 }
39}
40
41impl TryFrom<u8> for RequestCommandClass {
42 type Error = ();
43
44 fn try_from(value: u8) -> Result<Self, Self::Error> {
47 match value {
48 0x10 => Ok(Self::DiscoveryCommand),
49 0x20 => Ok(Self::GetCommand),
50 0x30 => Ok(Self::SetCommand),
51 _ => Err(()),
52 }
53 }
54}
55
56impl TryFrom<u8> for ResponseCommandClass {
57 type Error = ();
58
59 fn try_from(value: u8) -> Result<Self, Self::Error> {
62 match value {
63 0x11 => Ok(Self::DiscoveryCommandResponse),
64 0x21 => Ok(Self::GetCommandResponse),
65 0x31 => Ok(Self::SetCommandResponse),
66 _ => Err(()),
67 }
68 }
69}