scanAsync

@RequiresPermission(anyOf = ["android.permission.BLUETOOTH_ADMIN", "android.permission.BLUETOOTH_SCAN"])
fun scanAsync(filters: List<ScanFilter>? = null, settings: ScanSettings? = null, duration: Long = DEFAULT_TIMEOUT, onFinish: Callback<Array<BLEDevice>>? = null, onDiscover: Callback<BLEDevice>? = null, onUpdate: Callback<List<BLEDevice>>? = null, onError: Callback<Int>? = null)

Starts a scan for bluetooth devices Can be used without duration running until stopScan is called.

If only one device is required consider using scanFor

Parameters

filters

Used to specify attributes of the devices on the scan

settings

Native object to specify the scan settings (The default setting is only recommended for really fast scans)

duration

Scan time limit, when exceeded stops the scan (Ignored when less then 0)

Callbacks:

onFinish

Called when the scan is finished with an Array of Bluetooth devices found

onDiscover

Called whenever a new bluetooth device if found (Useful on realtime scans)

onUpdate

Called whenever the list changes (e.g new device discovered, device name changed etc...)

onError

Called whenever an error occurs on the scan (Of which will be automatically halted in case of errors)

See also

For a variation using coroutines suspended functions