Bluetooth

class Bluetooth(coroutineContext: CoroutineContext, scanningStateRepoBuilder: (CoroutineContext) -> ScanningStateFlowRepo) : BluetoothService, CoroutineScope

A BluetoothService that uses a ScanningStateFlowRepo to manage the ScanningState

Parameters

coroutineContext

the CoroutineContext in which Bluetooth runs

scanningStateRepoBuilder

method for creating a the ScanningStateFlowRepo to contain the ScanningState of the Bluetooth service

Constructors

Link copied to clipboard
constructor(coroutineContext: CoroutineContext, scanningStateRepoBuilder: (CoroutineContext) -> ScanningStateFlowRepo)

Properties

Link copied to clipboard
Link copied to clipboard
open override val isEnabled: Flow<Boolean>

A Flow that indicates whether Bluetooth is currently enabled. When false, Bluetooth might be unavailable or permissions may be missing.

Functions

Link copied to clipboard
open override fun allDevices(): Flow<List<Device>>

Gets a Flow containing a list of all Device scanned by the service. Requires that startScanning has been called, otherwise no devices will be found

Link copied to clipboard
open override fun devices(): Flow<List<Device>>

Gets a Flow containing a list of all Device scanned by the service for the last Filter passed to startScanning. Requires that startScanning has been called with filter, otherwise no devices will be found

Link copied to clipboard
open suspend override fun isScanning(): Flow<Boolean>

Gets a Flow that indicates whether the service is actively scanning for Device

Link copied to clipboard
open override fun pairedDevices(filter: Filter, removeForAllPairedFilters: Boolean, connectionSettings: ConnectionSettings?): Flow<List<Device>>

Gets a Flow of the list of Device that have been paired to the system

Link copied to clipboard
open override fun scannedDevices(filter: Filter): Flow<List<Device>>

Gets a Flow containing a list of all Device scanned by the service for a given Filter. Requires that startScanning has been called with filter, otherwise no devices will be found

Link copied to clipboard
open override fun startScanning(filter: Filter, cleanMode: BluetoothService.CleanMode, connectionSettings: ConnectionSettings?)

Starts scanning for Device. To receive the devices, use scannedDevices or allDevices

Link copied to clipboard
open override fun stopScanning(cleanMode: BluetoothService.CleanMode)

Stops scanning for Device