Exposing Android ScanSettings #158
-
Our app makes constant use of Bluetooth and involves a lot of scanning for nearby devices. In several parts of our app, scanning needs to return results as fast as possible, which means using ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.setReportDelay(0L)
.build() It looks like the current implementation of ScanSettings.Builder().build() which makes sense. That said, it would be really nice to be able to specify additional scan settings like we need above. I wonder if this could happen via a new variable in the public actual class ScannerBuilder {
public actual var services: List<Uuid>? = null
public var scanSettings: ScanSettings = ScanSettings.Builder().build() // new, defaults to existing default scan settings
... This would allow users who need to be able to customize scan settings to instantiate their scanner in their Android module but still let those that don't need that capability instantiate their scanner in common code. That feels ideal because scan settings like these aren't really multiplatform in nature (e.g. iOS doesn't even allow for controlling a scan mode or anything like it). Thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
All really good points. As an Android-only API in Kable (to allow creating a This seems like a fairly small change, would be happy to accept a PR if you want to take that on. Otherwise I can get to it once other higher priority bugs are addressed. |
Beta Was this translation helpful? Give feedback.
All really good points. As an Android-only API in Kable (to allow creating a
Scanner
with Android'sScanSettings
) sounds totally feasible.This seems like a fairly small change, would be happy to accept a PR if you want to take that on. Otherwise I can get to it once other higher priority bugs are addressed.