BluetoothL2CapChannel class

An open L2CAP connection-oriented channel: a bidirectional byte stream to the peer that runs alongside — but independently of — GATT.

Obtain one with BluetoothDevice.openL2capChannel. Read from input, write with write, and release it with close. The channel also closes on its own when the peer closes it or the device disconnects; watch input's done event (or isClosed).

Unlike GATT operations, reads and writes here do not pass through the global operation queue — the channel is a separate transport, so its throughput is not gated by (and does not gate) characteristic I/O.

Properties

channelId int
Native-assigned id, unique among channels for the plugin's lifetime.
final
device BluetoothDevice
final
hashCode int
The hash code for this object.
no setterinherited
input Stream<Uint8List>
Inbound bytes from the peer, as a single-subscription stream. Pausing the subscription backpressures the peer; the stream is done when the channel closes. Chunk boundaries are not significant — L2CAP is a byte stream.
no setter
isClosed bool
Whether the channel has been closed — by close, the peer, or a disconnect.
no setter
psm int
The PSM this channel was opened to.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close({Duration timeout = const Duration(seconds: 10)}) Future<void>
Closes the channel. Idempotent; safe to call after a remote close.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
write(Uint8List data, {Duration timeout = const Duration(seconds: 30)}) Future<void>
Writes data to the peer, completing once the platform has accepted the bytes (its backpressure signal). Throws if the channel is already closed.

Operators

operator ==(Object other) bool
The equality operator.
inherited