1use crate::command::network_service::types::Error as NetworkError;
2
3#[derive(Debug, PartialEq, Eq)]
4#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5pub enum GenericError {
6 Timeout,
7 Clock,
8 Unsupported,
9}
10
11#[derive(Debug, PartialEq)]
12#[non_exhaustive]
13pub enum Error {
14 BaudDetection,
16 SimCard,
17 Busy,
18 Uninitialized,
19 StateTimeout,
20 PoweredDown,
21 AttachTimeout,
22 ContextActivationTimeout,
23 InvalidStateTransition,
24
25 Network(NetworkError),
27
28 Generic(GenericError),
33
34 Atat(atat::Error),
35
36 _Unknown,
37
38 IoPin,
39
40 SubscriberOverflow(embassy_sync::pubsub::Error),
41}
42
43impl From<embassy_time::TimeoutError> for Error {
44 fn from(_value: embassy_time::TimeoutError) -> Self {
45 Error::Generic(GenericError::Timeout)
46 }
47}
48
49#[cfg(feature = "defmt")]
50impl defmt::Format for Error {
51 fn format(&self, f: defmt::Formatter<'_>) {
52 match self {
53 Self::BaudDetection => defmt::write!(f, "BaudDetection"),
54 Self::Busy => defmt::write!(f, "Busy"),
55 Self::Uninitialized => defmt::write!(f, "Uninitialized"),
56 Self::StateTimeout => defmt::write!(f, "StateTimeout"),
57 Self::PoweredDown => defmt::write!(f, "PoweredDown"),
58 Self::AttachTimeout => defmt::write!(f, "AttachTimeout"),
59 Self::ContextActivationTimeout => defmt::write!(f, "ContextActivationTimeout"),
60 Self::InvalidStateTransition => defmt::write!(f, "InvalidStateTransition"),
61 Self::Network(e) => defmt::write!(f, "Network({:?})", e),
62 Self::Generic(e) => defmt::write!(f, "Generic({:?})", e),
64 Self::Atat(e) => defmt::write!(f, "Atat({:?})", e),
65 Self::_Unknown => defmt::write!(f, "_Unknown"),
66 Self::SimCard => defmt::write!(f, "SimCard"),
67 Self::IoPin => defmt::write!(f, "IoPin"),
68 Self::SubscriberOverflow(e) => defmt::write!(f, "SubscriberOverflow({:?})", e),
69 _ => defmt::write!(f, "non_exhaustive"),
70 }
71 }
72}
73
74impl From<atat::Error> for Error {
75 fn from(e: atat::Error) -> Self {
76 Self::Atat(e)
77 }
78}