scan
Scans for Bluetooth LE devices.
The scan will be stopped after the given period of time or when the flow is canceled.
Results are queued while the collector is busy, and a collector that falls behind loses some of them. To choose which ones are kept, apply conflate() or a buffer with DROP_OLDEST or DROP_LATEST to the returned flow, e.g. buffer(64, DROP_LATEST).
The scan starts when the returned flow is collected, and all errors are thrown then, to the collector, not when this method is called. They can be handled using Flow.catch().
Parameters
The scan duration. By default, the scan will run until the flow is closed.
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.