BBDevice class

A single BLE peripheral discovered by a BBManager scan.

BBDevice instances are created and owned by BBManager -- you never construct one yourself, you get one from BBManager.devices or BBScanResult.device. The same instance is reused across repeated discoveries, connects, and disconnects of the same physical peripheral.

All BLE operations (connect, disconnect, discoverServices, requestMtu, and the read/write/subscribe methods on BBCharacteristic) are queued and executed one at a time per device by the native SDK -- you don't need to serialize calls yourself.

Typical flow: connect, discover services, then read/write/subscribe to the characteristics that appear in services.

Constructors

BBDevice({required String id, required String? name})

Properties

connectionStatus BBDeviceConnectionStatus
The device's current connection state. Updates automatically on connect, disconnect, and unexpected link loss -- you don't need to poll it after calling connect/disconnect.
no setter
connectionStatusStream Stream<BBDeviceConnectionStatus>
Notifies with the updated connectionStatus every time it changes.
no setter
hashCode int
The hash code for this object.
no setterinherited
id String
The system-assigned identifier for this peripheral. Stable for the lifetime of the app, but not guaranteed to match across different installations of the same peripheral.
final
mtu int
The negotiated ATT MTU (Maximum Transmission Unit) in bytes, i.e. the largest amount of data that can be sent in a single read/write. Defaults to the BLE minimum until requestMtu is called and awaited.
no setter
mtuStream Stream<int>
Notifies with the updated mtu every time it changes.
no setter
name String?
The peripheral's name, if it has advertised or reported one. May be null, and may change (e.g. once connected, some peripherals report a more specific name than they advertised).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
services List<BBService>
Services discovered so far. Empty until discoverServices has been called and completed.
no setter
servicesStream Stream<List<BBService>>
Notifies with the updated services list every time it changes.
no setter

Methods

connect() Future<void>
Connects to the peripheral. Updates connectionStatus to BBDeviceConnectionStatus.connected on success.
disconnect() Future<void>
Disconnects from the peripheral. Updates connectionStatus to BBDeviceConnectionStatus.disconnected on success.
discoverServices() Future<void>
Discovers all of the peripheral's services and their characteristics, populating services. Requires an active connection.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
requestMtu(int mtu) Future<int>
Requests a larger ATT MTU and returns the negotiated size.
toString() String
A string representation of this object.
inherited

Operators

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