BluetoothDevice class

Implementers

Constructors

BluetoothDevice({required DeviceIdentifier remoteId})
BluetoothDevice.fromId(String remoteId)
Create a device from an id
BluetoothDevice.fromProto(BmBluetoothDevice p)

Properties

advName String
Advertised Named
no setter
bondState Stream<BluetoothBondState>
Get the current bondState of the device (Android Only)
no setter
connectionState Stream<BluetoothConnectionState>
The current connection state of our app to the device
no setter
disconnectReason DisconnectReason?
The most recent disconnection reason
no setter
hashCode int
The hash code for this object.
no setteroverride
id DeviceIdentifier
no setter
isAutoConnectEnabled bool
Returns true if autoConnect is currently enabled for this device
no setter
isConnected bool
Returns true if this device is currently connected to your app
no setter
isDisconnected bool
Returns true if this device is currently disconnected from your app
no setter
isDiscoveringServices Stream<bool>
no setter
localName String
no setter
mtu Stream<int>
Stream emits a value:
no setter
mtuNow int
The current MTU size in bytes
no setter
name String
no setter
onServicesReset Stream<void>
Services Reset Stream
no setter
platformName String
platform name
no setter
prevBondState BluetoothBondState?
Get the previous bondState of the device (Android Only)
no setter
remoteId DeviceIdentifier
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
services Stream<List<BluetoothService>>
no setter
servicesList List<BluetoothService>
Get services
no setter
servicesStream Stream<List<BluetoothService>>
no setter
state Stream<BluetoothConnectionState>
no setter

Methods

cancelWhenDisconnected(StreamSubscription subscription, {bool next = false, bool delayed = false}) → void
Register a subscription to be canceled when the device is disconnected. This function simplifies cleanup, so you can prevent creating duplicate stream subscriptions.
clearGattCache() Future<void>
Refresh ble services & characteristics (Android Only)
connect({Duration timeout = const Duration(seconds: 35), int? mtu = 512, bool autoConnect = false}) Future<void>
Establishes a connection to the Bluetooth Device. timeout if timeout occurs, cancel the connection request and throw exception mtu Android only. Request a larger mtu right after connection, if set. autoConnect reconnect whenever the device is found - if true, this function always returns immediately. - you must listen to connectionState to know when connection occurs. - auto connect is turned off by calling disconnect - auto connect results in a slower connection process compared to a direct connection because it relies on the internal scheduling of background scans.
createBond({int timeout = 90}) Future<void>
Force the bonding popup to show now (Android Only) Note! calling this is usually not necessary!! The platform does it automatically.
disconnect({int timeout = 35, bool queue = true}) Future<void>
Cancels connection to the Bluetooth Device
discoverServices({bool subscribeToServicesChanged = true, int timeout = 15}) Future<List<BluetoothService>>
Discover services, characteristics, and descriptors of the remote device
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pair() Future<void>
readRssi({int timeout = 15}) Future<int>
Read the RSSI of connected remote device
removeBond({int timeout = 30}) Future<void>
Remove bond (Android Only)
requestConnectionPriority({required ConnectionPriority connectionPriorityRequest}) Future<void>
Request connection priority update (Android only)
requestMtu(int desiredMtu, {double predelay = 0.35, int timeout = 15}) Future<int>
Request to change MTU (Android Only)
setPreferredPhy({required int txPhy, required int rxPhy, required PhyCoding option}) Future<void>
Set the preferred connection (Android Only)
toString() String
A string representation of this object.
override

Operators

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