summaryrefslogtreecommitdiff
path: root/nrf-softdevice
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2021-03-11 16:57:05 +0100
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2021-03-11 16:57:05 +0100
commit3904b955a2537fec0ac84593ad754e1aeeb029fe (patch)
tree708c110e9af1ba99c7edd3daecccf7baf760667d /nrf-softdevice
parente6a75b927199ce0ea2f22cd6e19d7aa878bbd474 (diff)
downloadnrf-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.rs3
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,