pub struct L2capChannel<'d> { /* private fields */ }
Expand description
Handle representing an L2CAP channel.
Implementations§
Source§impl<'d> L2capChannel<'d>
impl<'d> L2capChannel<'d>
Sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
Disconnect this channel.
Sourcepub async fn send<T: Controller, const TX_MTU: usize>(
&mut self,
stack: &Stack<'_, T>,
buf: &[u8],
) -> Result<(), BleHostError<T::Error>>
pub async fn send<T: Controller, const TX_MTU: usize>( &mut self, stack: &Stack<'_, T>, buf: &[u8], ) -> Result<(), BleHostError<T::Error>>
Send the provided buffer over this l2cap channel.
The buffer will be segmented to the maximum payload size agreed in the opening handshake.
If the channel has been closed or the channel id is not valid, an error is returned. If there are no available credits to send, waits until more credits are available.
Sourcepub fn try_send<T: Controller + Controller, const TX_MTU: usize>(
&mut self,
stack: &Stack<'_, T>,
buf: &[u8],
) -> Result<(), BleHostError<T::Error>>
pub fn try_send<T: Controller + Controller, const TX_MTU: usize>( &mut self, stack: &Stack<'_, T>, buf: &[u8], ) -> Result<(), BleHostError<T::Error>>
Send the provided buffer over this l2cap channel.
The buffer will be segmented to the maximum payload size agreed in the opening handshake.
If the channel has been closed or the channel id is not valid, an error is returned. If there are no available credits to send, returns Error::Busy.
Sourcepub async fn receive<T: Controller>(
&mut self,
stack: &Stack<'_, T>,
buf: &mut [u8],
) -> Result<usize, BleHostError<T::Error>>
pub async fn receive<T: Controller>( &mut self, stack: &Stack<'_, T>, buf: &mut [u8], ) -> Result<usize, BleHostError<T::Error>>
Receive data on this channel and copy it into the buffer.
The length provided buffer slice must be equal or greater to the agreed MTU.
Sourcepub async fn accept<T: Controller>(
stack: &'d Stack<'d, T>,
connection: &Connection<'_>,
psm: &[u16],
config: &L2capChannelConfig,
) -> Result<Self, BleHostError<T::Error>>
pub async fn accept<T: Controller>( stack: &'d Stack<'d, T>, connection: &Connection<'_>, psm: &[u16], config: &L2capChannelConfig, ) -> Result<Self, BleHostError<T::Error>>
Await an incoming connection request matching the list of PSM.
Sourcepub async fn create<T: Controller>(
stack: &'d Stack<'d, T>,
connection: &Connection<'_>,
psm: u16,
config: &L2capChannelConfig,
) -> Result<Self, BleHostError<T::Error>>
pub async fn create<T: Controller>( stack: &'d Stack<'d, T>, connection: &Connection<'_>, psm: u16, config: &L2capChannelConfig, ) -> Result<Self, BleHostError<T::Error>>
Create a new connection request with the provided PSM.
Sourcepub fn split(self) -> (L2capChannelWriter<'d>, L2capChannelReader<'d>)
pub fn split(self) -> (L2capChannelWriter<'d>, L2capChannelReader<'d>)
Split the channel into a writer and reader for concurrently writing to/reading from the channel.
Sourcepub fn merge(
writer: L2capChannelWriter<'d>,
reader: L2capChannelReader<'d>,
) -> Self
pub fn merge( writer: L2capChannelWriter<'d>, reader: L2capChannelReader<'d>, ) -> Self
Merge writer and reader into a single channel again.
This function will panic if the channels are not referring to the same channel id.