1#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub enum LorawanError {
6 PayloadTooLong,
8 FrameTooShort,
10 UnsupportedMType(u8),
12 MicMismatch,
14 FcntMismatch,
16 MalformedFrame,
18}
19
20impl core::fmt::Display for LorawanError {
21 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
22 match self {
23 LorawanError::PayloadTooLong => {
24 f.write_str("lorawan payload does not fit a single frame")
25 }
26 LorawanError::FrameTooShort => {
27 f.write_str("lorawan frame is shorter than its header and MIC")
28 }
29 LorawanError::UnsupportedMType(mtype) => {
30 write!(f, "lorawan message type {mtype:#04x} is not decoded here")
31 }
32 LorawanError::MicMismatch => f.write_str("lorawan MIC does not match the frame"),
33 LorawanError::FcntMismatch => {
34 f.write_str("lorawan frame counter does not match the one expected")
35 }
36 LorawanError::MalformedFrame => f.write_str("lorawan frame is malformed"),
37 }
38 }
39}
40
41impl core::error::Error for LorawanError {}