mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-16 19:26:12 -04:00
Log scan result delay and increase minimum delay, lowest we could get was 5s anyways.
This commit is contained in:
@@ -34,13 +34,22 @@ class BleScanner @Inject constructor(
|
|||||||
val scanner = bluetoothManager.scanner
|
val scanner = bluetoothManager.scanner
|
||||||
|
|
||||||
val callback = object : ScanCallback() {
|
val callback = object : ScanCallback() {
|
||||||
|
var lastScanAt = System.currentTimeMillis()
|
||||||
override fun onScanResult(callbackType: Int, result: ScanResult) {
|
override fun onScanResult(callbackType: Int, result: ScanResult) {
|
||||||
log(TAG, VERBOSE) { "onScanResult(callbackType=$callbackType, result=$result)" }
|
log(TAG, VERBOSE) {
|
||||||
|
val delay = System.currentTimeMillis() - lastScanAt
|
||||||
|
lastScanAt = System.currentTimeMillis()
|
||||||
|
"onScanResult(delay=${delay}ms, callbackType=$callbackType, result=$result)"
|
||||||
|
}
|
||||||
trySend(listOf(BleScanResult.fromScanResult(result)))
|
trySend(listOf(BleScanResult.fromScanResult(result)))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBatchScanResults(results: MutableList<ScanResult>) {
|
override fun onBatchScanResults(results: MutableList<ScanResult>) {
|
||||||
log(TAG, VERBOSE) { "onBatchScanResults(results=$results)" }
|
log(TAG, VERBOSE) {
|
||||||
|
val delay = System.currentTimeMillis() - lastScanAt
|
||||||
|
lastScanAt = System.currentTimeMillis()
|
||||||
|
"onBatchScanResults(delay=${delay}ms, results=$results)"
|
||||||
|
}
|
||||||
trySend(results.map { BleScanResult.fromScanResult(it) })
|
trySend(results.map { BleScanResult.fromScanResult(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +61,7 @@ class BleScanner @Inject constructor(
|
|||||||
val settings = ScanSettings.Builder().apply {
|
val settings = ScanSettings.Builder().apply {
|
||||||
setScanMode(mode)
|
setScanMode(mode)
|
||||||
if (adapter.isOffloadedScanBatchingSupported) {
|
if (adapter.isOffloadedScanBatchingSupported) {
|
||||||
setReportDelay(100)
|
setReportDelay(1000)
|
||||||
} else {
|
} else {
|
||||||
log(TAG, WARN) { "isOffloadedScanBatchingSupported=false" }
|
log(TAG, WARN) { "isOffloadedScanBatchingSupported=false" }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user