#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LorawanError {
PayloadTooLong,
FrameTooShort,
UnsupportedMType(u8),
MicMismatch,
FcntMismatch,
MalformedFrame,
}
impl core::fmt::Display for LorawanError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
LorawanError::PayloadTooLong => {
f.write_str("lorawan payload does not fit a single frame")
}
LorawanError::FrameTooShort => {
f.write_str("lorawan frame is shorter than its header and MIC")
}
LorawanError::UnsupportedMType(mtype) => {
write!(f, "lorawan message type {mtype:#04x} is not decoded here")
}
LorawanError::MicMismatch => f.write_str("lorawan MIC does not match the frame"),
LorawanError::FcntMismatch => {
f.write_str("lorawan frame counter does not match the one expected")
}
LorawanError::MalformedFrame => f.write_str("lorawan frame is malformed"),
}
}
}
impl core::error::Error for LorawanError {}