@@ -23,6 +23,7 @@ enum ControlByte {
2323 Error = 0xEFu8 ,
2424}
2525
26+ /// Fundamental struct for controlling a connected ESP32-WROOM NINA firmware-based Wifi board.
2627#[ derive( Debug , Default ) ]
2728pub struct Wifi < B , C > {
2829 common : WifiCommon < NinaProtocolHandler < B , C > > ,
6869 self . common . leave ( )
6970 }
7071
72+ /// Retrieves the current WiFi network connection status.
73+ ///
74+ /// NOTE: A future version will provide a enumerated type instead of the raw integer values
75+ /// from the NINA firmware.
7176 pub fn get_connection_status ( & mut self ) -> Result < u8 , Error > {
7277 self . common . get_connection_status ( )
7378 }
9398 let operation =
9499 Operation :: new ( NinaCommand :: GetFwVersion , 1 ) . with_no_params ( NinaNoParams :: new ( "" ) ) ;
95100
96- self . execute ( & operation) ;
101+ self . execute ( & operation) . ok ( ) . unwrap ( ) ;
97102
98103 let result = self . receive ( & operation) ?;
99104
@@ -105,17 +110,17 @@ where
105110 . param ( NinaSmallArrayParam :: new ( ssid) )
106111 . param ( NinaSmallArrayParam :: new ( passphrase) ) ;
107112
108- self . execute ( & operation) ;
113+ self . execute ( & operation) . ok ( ) . unwrap ( ) ;
109114
110- self . receive ( & operation) ;
115+ self . receive ( & operation) . ok ( ) . unwrap ( ) ;
111116 Ok ( ( ) )
112117 }
113118
114119 fn get_conn_status ( & mut self ) -> Result < u8 , self :: Error > {
115120 let operation =
116121 Operation :: new ( NinaCommand :: GetConnStatus , 1 ) . with_no_params ( NinaNoParams :: new ( "" ) ) ;
117122
118- self . execute ( & operation) ;
123+ self . execute ( & operation) . ok ( ) . unwrap ( ) ;
119124
120125 let result = self . receive ( & operation) ?;
121126
@@ -126,9 +131,9 @@ where
126131 let dummy_param = NinaByteParam :: from_bytes ( & [ ControlByte :: Dummy as u8 ] ) ;
127132 let operation = Operation :: new ( NinaCommand :: Disconnect , 1 ) . param ( dummy_param) ;
128133
129- self . execute ( & operation) ;
134+ self . execute ( & operation) . ok ( ) . unwrap ( ) ;
130135
131- self . receive ( & operation) ;
136+ self . receive ( & operation) . ok ( ) . unwrap ( ) ;
132137
133138 Ok ( ( ) )
134139 }
@@ -143,16 +148,16 @@ where
143148 let mut param_size: u16 = 0 ;
144149 self . control_pins . wait_for_esp_select ( ) ;
145150
146- self . send_cmd ( & operation. command , operation. params . len ( ) as u8 ) ;
151+ self . send_cmd ( & operation. command , operation. params . len ( ) as u8 ) . ok ( ) . unwrap ( ) ;
147152
148153 // Only send params if they are present
149154 if operation. has_params {
150155 operation. params . iter ( ) . for_each ( |param| {
151- self . send_param ( param) ;
156+ self . send_param ( param) . ok ( ) . unwrap ( ) ;
152157 param_size += param. length ( ) ;
153158 } ) ;
154159
155- self . send_end_cmd ( ) ;
160+ self . send_end_cmd ( ) . ok ( ) . unwrap ( ) ;
156161
157162 // This is to make sure we align correctly
158163 // 4 (start byte, command byte, reply byte, end byte) + the sum of all param lengths
@@ -320,6 +325,7 @@ where
320325 }
321326}
322327
328+ #[ allow( dead_code) ]
323329/// Error which occurred during a SPI transaction with a target ESP32 device
324330#[ derive( Clone , Copy , Debug ) ]
325331pub enum SPIError < SPIE , IOE > {
0 commit comments