monitor

abstract fun monitor(timeout: Duration = Duration.INFINITE, filter: F.() -> Unit): Flow<MonitoringEvent<P>>

Starts monitoring for Bluetooth LE devices.

This method will emit events when the monitoring device enters or leaves the range of a peripheral advertising packets matching given filter.

The scan will be stopped after the given period of time or when the flow is cancelled.

Parameters

timeout

The scan duration. By default the scan will run until the flow is closed.

filter

The filter to apply. By default no filter is applied.

Throws

If the central manager has been closed.

If Bluetooth is disabled or not available.

If the permission to scan is denied.

If an error occurred while starting the scan.