Interface IBluetoothRemoteL2CapChannel
- Namespace
- Bluetooth.Abstractions.Scanning
- Assembly
- Bluetooth.Abstractions.Scanning.dll
Interface representing a Bluetooth L2CAP (Logical Link Control and Adaptation Protocol) channel. L2CAP channels provide connection-oriented data transfer with higher throughput than GATT characteristics.
public interface IBluetoothRemoteL2CapChannel : INotifyPropertyChanged, IAsyncDisposable
- Inherited Members
Properties
Device
Gets the device associated with this L2CAP channel.
IBluetoothRemoteDevice Device { get; }
Property Value
IsOpen
Gets a value indicating whether the channel is currently open.
bool IsOpen { get; }
Property Value
Psm
Gets the Protocol Service Multiplexer (PSM) value for this channel.
int Psm { get; }
Property Value
Methods
CloseAsync(TimeSpan?, CancellationToken)
Closes the L2CAP channel asynchronously.
ValueTask CloseAsync(TimeSpan? timeout = null, CancellationToken cancellationToken = default)
Parameters
timeoutTimeSpan?The timeout for this operation.
cancellationTokenCancellationTokenA cancellation token to cancel this operation.
Returns
- ValueTask
A task that represents the asynchronous close operation.
Exceptions
- InvalidOperationException
Thrown when the channel is not open.
- TimeoutException
Thrown when the operation times out.
- OperationCanceledException
Thrown when the operation is cancelled.
OpenAsync(TimeSpan?, CancellationToken)
Opens the L2CAP channel asynchronously.
ValueTask OpenAsync(TimeSpan? timeout = null, CancellationToken cancellationToken = default)
Parameters
timeoutTimeSpan?The timeout for this operation.
cancellationTokenCancellationTokenA cancellation token to cancel this operation.
Returns
- ValueTask
A task that represents the asynchronous open operation.
Exceptions
- InvalidOperationException
Thrown when the channel is already open.
- TimeoutException
Thrown when the operation times out.
- OperationCanceledException
Thrown when the operation is cancelled.
ReadAsync(Memory<byte>, TimeSpan?, CancellationToken)
Reads data from the L2CAP channel asynchronously.
ValueTask<int> ReadAsync(Memory<byte> buffer, TimeSpan? timeout = null, CancellationToken cancellationToken = default)
Parameters
bufferMemory<byte>The buffer to read data into.
timeoutTimeSpan?The timeout for this operation.
cancellationTokenCancellationTokenA cancellation token to cancel this operation.
Returns
- ValueTask<int>
A task that represents the asynchronous read operation. The task result contains the number of bytes read.
WriteAsync(ReadOnlyMemory<byte>, TimeSpan?, CancellationToken)
Writes data to the L2CAP channel asynchronously.
ValueTask WriteAsync(ReadOnlyMemory<byte> data, TimeSpan? timeout = null, CancellationToken cancellationToken = default)
Parameters
dataReadOnlyMemory<byte>The data to write.
timeoutTimeSpan?The timeout for this operation.
cancellationTokenCancellationTokenA cancellation token to cancel this operation.
Returns
- ValueTask
A task that represents the asynchronous write operation.
Exceptions
- ArgumentNullException
Thrown when
datais null.- InvalidOperationException
Thrown when the channel is not open.
- TimeoutException
Thrown when the operation times out.
- OperationCanceledException
Thrown when the operation is cancelled.
Events
DataReceived
Event raised when data is received on the channel.
event EventHandler<L2CapDataReceivedEventArgs>? DataReceived