BaseScanner

abstract class BaseScanner(settings: BaseScanner.Settings, coroutineScope: CoroutineScope, scanningDispatcher: CoroutineDispatcher = com.splendo.kaluga.bluetooth.scanner.scanningDispatcher) : Scanner, CoroutineScope

An abstract implementation for Scanner

Parameters

settings

the Settings to configure this scanner

coroutineScope

the CoroutineScope this scanner runs on

scanningDispatcher

the CoroutineDispatcher to which scanning should be dispatched. It is recommended to make this a dispatcher that can handle high frequency of events

Inheritors

Constructors

Link copied to clipboard
constructor(settings: BaseScanner.Settings, coroutineScope: CoroutineScope, scanningDispatcher: CoroutineDispatcher = com.splendo.kaluga.bluetooth.scanner.scanningDispatcher)

Types

Link copied to clipboard
interface Builder

Builder for creating a BaseScanner

Link copied to clipboard
object Companion
Link copied to clipboard
data class Settings(val permissions: Permissions, val autoRequestPermission: Boolean = true, val autoEnableSensors: Boolean = true, val discoverBondedDevices: Boolean = true, val defaultConnectionSettings: ConnectionSettings = ConnectionSettings(), val logger: Logger = RestrictedLogger(RestrictedLogLevel.None))

Settings to configure a BaseScanner

Properties

Link copied to clipboard
open override val connectionEvents: Flow<Scanner.ConnectionEvent>

The Flow of all the ConnectionEvent detected by the scanner

Link copied to clipboard
Link copied to clipboard

The Flow of all the DeviceDiscovered detected by the scanner. These are grouped in a list until collected to account for high volumes of events

Link copied to clipboard
open override val events: Flow<Scanner.Event>

The Flow of all the Event detected by the scanner

Link copied to clipboard
abstract val isSupported: Boolean

Indicates whether the system supports Bluetooth scanning

Functions

Link copied to clipboard
open override fun cancelRetrievingPairedDevices()
Link copied to clipboard
open suspend override fun isHardwareEnabled(): Boolean

Checks whether the Bluetooth service is currently enabled

Link copied to clipboard
open suspend override fun requestEnableHardware()

Attempts to request the user to enable Bluetooth

Link copied to clipboard
open suspend override fun retrievePairedDevices(withServices: Filter, removeForAllPairedFilters: Boolean, connectionSettings: ConnectionSettings?)

Retrieves the list of paired Device This will result in Event.PairedDevicesRetrieved on the events flow

Link copied to clipboard
suspend override fun scanForDevices(filter: Filter, connectionSettings: ConnectionSettings?)

Starts scanning for devices. This will result in Event.DeviceDiscovered or Event.FailedScanning

Link copied to clipboard
open suspend override fun startMonitoringHardwareEnabled()

Starts scanning for changes to the Bluetooth service being enabled This will result in Event.BluetoothEnabled or Event.BluetoothDisabled on the events flow

Link copied to clipboard
open suspend override fun startMonitoringPermissions()

Starts scanning for changes to permissions related to Bluetooth. This will result in Event.PermissionChanged on the events flow.

Link copied to clipboard
open suspend override fun stopMonitoringHardwareEnabled()

Stops scanning for changes to the Bluetooth service being enabled

Link copied to clipboard
open suspend override fun stopMonitoringPermissions()

Stops scanning for changes to permissions related to Bluetooth.

Link copied to clipboard
suspend override fun stopScanning()

Stops scanning for devices