pub struct L2capManager { /* private fields */ }Expand description
L2CAP connection and channel manager
Implementations§
Source§impl L2capManager
impl L2capManager
Sourcepub fn channel_count(&self) -> usize
pub fn channel_count(&self) -> usize
Get number of active channels
Sourcepub fn get_channel(&self, local_cid: u16) -> Option<&L2capChannel>
pub fn get_channel(&self, local_cid: u16) -> Option<&L2capChannel>
Get a channel by local CID
Sourcepub fn get_channel_mut(&mut self, local_cid: u16) -> Option<&mut L2capChannel>
pub fn get_channel_mut(&mut self, local_cid: u16) -> Option<&mut L2capChannel>
Get a mutable reference to a channel by local CID
Sourcepub fn open_channel(
&mut self,
psm: u16,
hci_handle: u16,
) -> Result<(u16, SignalingCommand), KernelError>
pub fn open_channel( &mut self, psm: u16, hci_handle: u16, ) -> Result<(u16, SignalingCommand), KernelError>
Open a new L2CAP channel for the given PSM on the given HCI connection
Returns (local_cid, SignalingCommand to send to peer)
Sourcepub fn close_channel(
&mut self,
local_cid: u16,
) -> Result<SignalingCommand, KernelError>
pub fn close_channel( &mut self, local_cid: u16, ) -> Result<SignalingCommand, KernelError>
Close an existing L2CAP channel
Returns a SignalingCommand (Disconnection Request) to send to peer
Sourcepub fn remove_channel(&mut self, local_cid: u16) -> Option<L2capChannel>
pub fn remove_channel(&mut self, local_cid: u16) -> Option<L2capChannel>
Remove a channel entirely (after disconnection completes)
Sourcepub fn send_data(
&self,
local_cid: u16,
data: &[u8],
) -> Result<Vec<SarFragment>, KernelError>
pub fn send_data( &self, local_cid: u16, data: &[u8], ) -> Result<Vec<SarFragment>, KernelError>
Send data on an open channel, segmenting into PDU fragments if needed
Returns a list of SAR fragments ready to be sent over HCI ACL
Sourcepub fn receive_data(
&mut self,
local_cid: u16,
fragment: &[u8],
is_first: bool,
) -> Result<Option<Vec<u8>>, KernelError>
pub fn receive_data( &mut self, local_cid: u16, fragment: &[u8], is_first: bool, ) -> Result<Option<Vec<u8>>, KernelError>
Receive and reassemble data for a channel
Feeds a raw fragment into the reassembly buffer. Returns completed payload when all fragments have been received.
Sourcepub fn process_signaling(
&mut self,
cmd: &SignalingCommand,
) -> Result<Option<SignalingCommand>, KernelError>
pub fn process_signaling( &mut self, cmd: &SignalingCommand, ) -> Result<Option<SignalingCommand>, KernelError>
Process an incoming L2CAP signaling command
Returns an optional response command to send back
Sourcepub fn configure_channel(
&mut self,
local_cid: u16,
mtu: u16,
flush_timeout: u16,
) -> Result<(), KernelError>
pub fn configure_channel( &mut self, local_cid: u16, mtu: u16, flush_timeout: u16, ) -> Result<(), KernelError>
Configure a channel’s MTU and flush timeout