|
1 | 1 | pub use crate::spi::Wifi;
|
2 | 2 |
|
| 3 | +use defmt::{write, Format, Formatter}; |
| 4 | + |
3 | 5 | /// An enumerated type that represents the current WiFi network connection status.
|
4 | 6 | #[repr(u8)]
|
5 | 7 | #[derive(Eq, PartialEq, PartialOrd, Debug)]
|
@@ -48,3 +50,57 @@ impl From<u8> for ConnectionStatus {
|
48 | 50 | }
|
49 | 51 | }
|
50 | 52 | }
|
| 53 | + |
| 54 | +impl Format for ConnectionStatus { |
| 55 | + fn format(&self, fmt: Formatter) { |
| 56 | + match self { |
| 57 | + ConnectionStatus::NoEsp32 => write!( |
| 58 | + fmt,"No device is connected to hardware" |
| 59 | + ), |
| 60 | + ConnectionStatus::Idle => write!( |
| 61 | + fmt, |
| 62 | + "Temporary status while attempting to connect to WiFi network" |
| 63 | + ), |
| 64 | + ConnectionStatus::NoActiveSsid => write!( |
| 65 | + fmt, |
| 66 | + "No SSID is available" |
| 67 | + ), |
| 68 | + ConnectionStatus::ScanCompleted => write!( |
| 69 | + fmt, |
| 70 | + "WiFi network scan has finished" |
| 71 | + ), |
| 72 | + ConnectionStatus::Connected => write!( |
| 73 | + fmt, |
| 74 | + "Device is connected to WiFi network" |
| 75 | + ), |
| 76 | + ConnectionStatus::Failed => write!( |
| 77 | + fmt, |
| 78 | + "Device failed to connect to WiFi network" |
| 79 | + ), |
| 80 | + ConnectionStatus::Lost => write!( |
| 81 | + fmt, |
| 82 | + "Device lost connection to WiFi network" |
| 83 | + ), |
| 84 | + ConnectionStatus::Disconnected => write!( |
| 85 | + fmt, |
| 86 | + "Device disconnected from WiFi network" |
| 87 | + ), |
| 88 | + ConnectionStatus::ApListening => write!( |
| 89 | + fmt, |
| 90 | + "Device is lstening for connections in Access Point mode" |
| 91 | + ), |
| 92 | + ConnectionStatus::ApConnected => write!( |
| 93 | + fmt, |
| 94 | + "Device is connected in Access Point mode" |
| 95 | + ), |
| 96 | + ConnectionStatus::ApFailed => write!( |
| 97 | + fmt, |
| 98 | + "Device failed to make connection in Access Point mode" |
| 99 | + ), |
| 100 | + ConnectionStatus::Invalid => write!( |
| 101 | + fmt, |
| 102 | + "Unexpected value returned from device, reset may be required" |
| 103 | + ), |
| 104 | + } |
| 105 | + } |
| 106 | +} |
0 commit comments