diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2021-03-11 16:57:05 +0100 |
---|---|---|
committer | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2021-03-11 16:57:05 +0100 |
commit | 3904b955a2537fec0ac84593ad754e1aeeb029fe (patch) | |
tree | 708c110e9af1ba99c7edd3daecccf7baf760667d /nrf-softdevice | |
parent | e6a75b927199ce0ea2f22cd6e19d7aa878bbd474 (diff) | |
download | nrf-softdevice-3904b955a2537fec0ac84593ad754e1aeeb029fe.zip |
Report allocation failure in l2cap rx instead of panicking.
Diffstat (limited to 'nrf-softdevice')
-rw-r--r-- | nrf-softdevice/src/ble/l2cap.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/nrf-softdevice/src/ble/l2cap.rs b/nrf-softdevice/src/ble/l2cap.rs index 29264a2..689fd1b 100644 --- a/nrf-softdevice/src/ble/l2cap.rs +++ b/nrf-softdevice/src/ble/l2cap.rs @@ -52,6 +52,7 @@ impl From<RawError> for TxError { #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum RxError { Disconnected, + AllocateFailed, Raw(RawError), } @@ -327,7 +328,7 @@ impl<P: Packet> Channel<P> { pub async fn rx(&self) -> Result<P, RxError> { let conn_handle = self.conn.with_state(|s| s.check_connected())?; - let ptr = unwrap!(P::allocate()); + let ptr = P::allocate().ok_or(RxError::AllocateFailed)?; let data = raw::ble_data_t { p_data: ptr.as_ptr(), len: P::MTU as u16, |