BluetoothManager class

Manages Bluetooth operations such as device discovery, connection, disconnection, and streaming data for BLE devices.

This class is responsible for handling all the Bluetooth-related operations and can be injected as a lazy singleton using a dependency injection system.

It is recommended that you access this class via the OptiConnect class and avoid direct initialization.

Annotations

Constructors

BluetoothManager(BleDevicesDiscoverer _bleDevicesDiscoverer, BleConnectivityHandler _bleConnectivityHandler, BleDevicesStreamsHandler _bleDevicesStreamsHandler, AppLogger _appLogger)
Constructs the BluetoothManager with injected dependencies.

Properties

adapterState Stream<BleAdapterState>
A stream of BleAdapterState representing the state of the Bluetooth adapter.
no setter
bleDiscoveredDevicesStream Stream<BleDiscoveredDevice>
A stream of BleDiscoveredDevice representing discovered BLE devices.
no setter
hashCode int
The hash code for this object.
no setterinherited
isBluetoothAvailable Future<bool>
Checks if Bluetooth is available on the device.
no setter
isScanning bool
Checks if the Bluetooth adapter is currently scanning for devices (discovery).
no setter
isScanningStream Stream<bool>
A stream of bool representing the scanning state.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

connect(String deviceId) Future<void>
Connects to the BLE device with the given deviceId.
disconnect(String deviceId) Future<void>
Disconnects from the BLE device with the given deviceId.
dispose() Future<void>
Cleans up BLE-related resources when no longer needed.
getLatestBatteryPercentage(String deviceId) int
Gets the latest battery percentage for the given deviceId.
getLatestBatteryStatus(String deviceId) BatteryLevelStatus
Gets the latest battery status for the given deviceId.
listenToConnectionState(String deviceId) Stream<BleDeviceConnectionState>
Listens to the connection state of the BLE device with the given deviceId.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startDiscovery() Future<void>
Starts the BLE device discovery process.
stopDiscovery() Future<void>
Stops the BLE device discovery process.
subscribeToBarcodeDataStream(String deviceId) Future<Stream<BarcodeData>>
Subscribes to the barcode data stream from the BLE device with the given deviceId.
subscribeToBatteryPercentageStream(String deviceId) Future<Stream<int>>
Subscribes to the battery percentage stream from the BLE device with the given deviceId.
subscribeToBatteryStatusStream(String deviceId) Future<Stream<BatteryLevelStatus>>
Subscribes to the battery status stream from the BLE device with the given deviceId.
toString() String
A string representation of this object.
inherited

Operators

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