FakeBluetoothRfcommPlatform class
A scriptable, in-memory BluetoothRfcommPlatform for tests.
Populate bonded, queue discoveryResults to emit, and connect against services. Each openRfcomm returns a FakeRfcommTransport you can drive: push inbound bytes with FakeRfcommTransport.deliver and inspect everything written via FakeRfcommTransport.sent.
- Inheritance
-
- Object
- BluetoothRfcommPlatform
- FakeBluetoothRfcommPlatform
Constructors
- FakeBluetoothRfcommPlatform({bool supported = true, BluetoothAdapterState adapterState = BluetoothAdapterState.on})
Properties
-
bonded
→ List<
BluetoothDevice> -
Bonded devices returned by bondedDevices.
final
- connectError ↔ Object?
-
If set, openRfcomm throws this instead of returning a transport.
getter/setter pair
- discoveryError ↔ Object?
-
If set, the discovery stream emits this error (after any discoveryResults)
so tests can exercise error-surfacing paths.
getter/setter pair
-
discoveryResults
→ List<
BluetoothDiscoveryResult> -
Sightings emitted (in order) when startDiscovery is listened to.
final
- discoveryStarted ↔ bool
-
getter/setter pair
- discoveryStopped ↔ bool
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
paired
→ List<
DeviceId> -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
services
→ Map<
DeviceId, List< BluetoothService> > -
SDP services returned by discoverServices, keyed by device id.
final
- supported ↔ bool
-
getter/setter pair
-
transports
→ List<
FakeRfcommTransport> -
Transports handed out by openRfcomm, in creation order.
final
-
unpaired
→ List<
DeviceId> -
final
Methods
-
adapterState(
) → Future< BluetoothAdapterState> -
Current adapter power/authorization state.
override
-
adapterStateChanges(
) → Stream< BluetoothAdapterState> -
Adapter state transitions. Broadcast; emits the current state on listen.
override
-
bondedDevices(
) → Future< List< BluetoothDevice> > -
Paired (bonded) devices known to the OS.
override
-
discoverServices(
DeviceId device, {Uuid? serviceUuid}) → Future< List< BluetoothService> > -
Resolves the RFCOMM services advertised by device
idvia SDP, optionally filtered to a singleserviceUuid.override -
dispose(
) → Future< void> -
Releases any global resources held by the backend.
override
-
emitAdapterState(
BluetoothAdapterState state) → void -
isSupported(
) → Future< bool> -
Whether this platform can do Bluetooth Classic RFCOMM at all.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openRfcomm(
DeviceId device, {int? channel, required Uuid serviceUuid, Duration? timeout}) → Future< RfcommTransport> -
Opens an RFCOMM channel to device
id. Ifchannelis given it is used verbatim; otherwise the channel is resolved from SDP forserviceUuid.override -
pair(
DeviceId device) → Future< void> -
Pairs with device
id. Optional capability — may throw BluetoothUnsupportedException.override -
setAdapterEnabled(
bool enabled) → Future< void> -
Requests the radio be powered on/off. Throws
BluetoothUnsupportedException where the OS forbids programmatic control.
override
-
startDiscovery(
) → Stream< BluetoothDiscoveryResult> -
Starts an inquiry and streams sightings. Cancelling the subscription (or
calling stopDiscovery) stops the inquiry on every backend except Windows,
where the inquiry runs to completion (~10s) on a worker isolate and its
results are delivered in one batch; cancelling there only discards them.
override
-
stopDiscovery(
) → Future< void> -
Stops any in-progress inquiry.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
unpair(
DeviceId device) → Future< void> -
Removes the bond with device
id. Optional capability.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
sampleDevice(
{String address = 'AA:BB:CC:DD:EE:FF', String name = 'Test Device'}) → BluetoothDevice - A ready-made sample device for convenience.