diff --git a/src/radio.rs b/src/radio.rs index 0fc9d2b36962e9b72abe086d9ab37f2fe0d6d3fd..f1a6a7fc8e74a94bdb6c5da9d8f303a9ecd4fe06 100644 --- a/src/radio.rs +++ b/src/radio.rs @@ -21,7 +21,7 @@ type MyDelay = Delay<TIM5, 1000000>; type Radio = Rf4463<Spi<SPI1>, SdnPin, CsPin, MyDelay>; pub struct RadioManager<'a> { - pub radio: Radio, + radio: Radio, buf: &'a mut [u8; MAX_PACKET_LEN], enable_digipeating: bool, } @@ -64,14 +64,17 @@ impl<'a> RadioManager<'a> { .map_err(TransferError::SpiError)?; } - self.radio.interrupt(Some(self.buf), None).unwrap(); + self.radio.interrupt(Some(self.buf), None)?; - if let Some(data) = self.radio.finish_rx(self.buf).unwrap() { + if let Some(data) = self + .radio + .finish_rx(self.buf) + .map_err(TransferError::SpiError)? + { if self.enable_digipeating { if let Some((callsign, ssid)) = ident { let mut buf = [0; MAX_PACKET_LEN]; - let p = Packet::fully_decode(data.data(), &mut buf); - if let Ok(packet) = p { + if let Ok(packet) = Packet::fully_decode(data.data(), &mut buf) { self.handle_packet_rx(led, packet, callsign, ssid); } }