Skip to content

Commit

Permalink
simplify acl handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lulf committed Mar 21, 2024
1 parent 347964a commit 97cae94
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
18 changes: 7 additions & 11 deletions host/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,7 @@ where
if let Some(mut p) = self.pool.alloc(ATT_ID) {
let len = packet.payload.len();
p.as_mut()[..len].copy_from_slice(packet.payload);
self.att_inbound
.send((
conn,
Pdu {
packet: p,
pb: acl.boundary_flag(),
len,
},
))
.await;
self.att_inbound.send((conn, Pdu { packet: p, len })).await;
} else {
// TODO: Signal back
}
Expand Down Expand Up @@ -310,7 +301,12 @@ where
// Task handling shuffling outbound ACL data.
let tx_fut = async {
let (handle, pdu) = self.outbound.receive().await;
let acl = AclPacket::new(handle, pdu.pb, AclBroadcastFlag::PointToPoint, pdu.as_ref());
let acl = AclPacket::new(
handle,
AclPacketBoundary::FirstNonFlushable,
AclBroadcastFlag::PointToPoint,
pdu.as_ref(),
);
match self.controller.write_acl_data(&acl).await {
Ok(_) => {}
Err(e) => {
Expand Down
12 changes: 2 additions & 10 deletions host/src/l2cap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ impl<'a, 'd, const MTU: usize> L2capChannel<'a, 'd, MTU> {
w.append(first)?;
w.len()
};
let pdu = if remaining.is_empty() {
Pdu::new(packet, len)
} else {
Pdu::new(packet, len)
};
let pdu = Pdu::new(packet, len);
self.tx.send((self.conn, pdu)).await;
} else {
return Err(Error::OutOfMemory);
Expand All @@ -105,11 +101,7 @@ impl<'a, 'd, const MTU: usize> L2capChannel<'a, 'd, MTU> {
w.append(chunk)?;
w.len()
};
let pdu = if i == num_chunks - 1 {
Pdu::new(packet, len)
} else {
Pdu::new(packet, len)
};
let pdu = Pdu::new(packet, len);
self.tx.send((self.conn, pdu)).await;
} else {
return Err(Error::OutOfMemory);
Expand Down
9 changes: 1 addition & 8 deletions host/src/pdu.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
use bt_hci::data::AclPacketBoundary;

use crate::packet_pool::Packet;

pub struct Pdu<'d> {
pub packet: Packet<'d>,
pub pb: AclPacketBoundary,
pub len: usize,
}

impl<'d> Pdu<'d> {
pub fn new(packet: Packet<'d>, len: usize) -> Self {
Self {
packet,
pb: AclPacketBoundary::FirstNonFlushable,
len,
}
Self { packet, len }
}
}

Expand Down

0 comments on commit 97cae94

Please sign in to comment.