Table of Contents

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

IBluetoothRemoteDevice

IsOpen

Gets a value indicating whether the channel is currently open.

bool IsOpen { get; }

Property Value

bool

Psm

Gets the Protocol Service Multiplexer (PSM) value for this channel.

int Psm { get; }

Property Value

int

Methods

CloseAsync(TimeSpan?, CancellationToken)

Closes the L2CAP channel asynchronously.

ValueTask CloseAsync(TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

timeout TimeSpan?

The timeout for this operation.

cancellationToken CancellationToken

A 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

timeout TimeSpan?

The timeout for this operation.

cancellationToken CancellationToken

A 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

buffer Memory<byte>

The buffer to read data into.

timeout TimeSpan?

The timeout for this operation.

cancellationToken CancellationToken

A 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

data ReadOnlyMemory<byte>

The data to write.

timeout TimeSpan?

The timeout for this operation.

cancellationToken CancellationToken

A cancellation token to cancel this operation.

Returns

ValueTask

A task that represents the asynchronous write operation.

Exceptions

ArgumentNullException

Thrown when data is 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

Event Type

EventHandler<L2CapDataReceivedEventArgs>