From 6e2fce02940bde40a2c8a48a725e9fa0157bde6c Mon Sep 17 00:00:00 2001 From: Prerepa Viswanadham Date: Fri, 30 May 2014 15:53:30 -0700 Subject: [PATCH] Set scan parameters in ScanClient based on BluetoothLeScanSettings configuration scan_mode scan_window_ms scan_interval_ms SCAN_MODE_LOW_POWER 500 5000 SCAN_MODE_BALANCED 1000 5000 SCAN_MODE_LOW_LATENCY 2500 5000 Change-Id: I2382c7b584b102555f175a94206c4379141af3fa --- src/com/android/bluetooth/gatt/ScanClient.java | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/com/android/bluetooth/gatt/ScanClient.java b/src/com/android/bluetooth/gatt/ScanClient.java index 5b0f5d4f..db7034bc 100644 --- a/src/com/android/bluetooth/gatt/ScanClient.java +++ b/src/com/android/bluetooth/gatt/ScanClient.java @@ -39,6 +39,16 @@ import java.util.UUID; */ private static final int LE_SCAN_INTERVAL_MS = 100; + /** + * Scan params corresponding to scan setting + */ + private static final int SCAN_MODE_LOW_POWER_WINDOW_MS = 500; + private static final int SCAN_MODE_LOW_POWER_INTERVAL_MS = 5000; + private static final int SCAN_MODE_BALANCED_WINDOW_MS = 1000; + private static final int SCAN_MODE_BALANCED_INTERVAL_MS = 5000; + private static final int SCAN_MODE_LOW_LATENCY_WINDOW_MS = 2500; + private static final int SCAN_MODE_LOW_LATENCY_INTERVAL_MS = 5000; + int appIf; boolean isServer; UUID[] uuids; @@ -73,5 +83,25 @@ import java.util.UUID; this.scanInterval = scanInterval; this.settings = settings; this.filters = filters; + if (settings != null) { + switch (settings.getScanMode()) { + case BluetoothLeScanSettings.SCAN_MODE_LOW_POWER: + this.scanWindow = SCAN_MODE_LOW_POWER_WINDOW_MS; + this.scanInterval = SCAN_MODE_LOW_POWER_INTERVAL_MS; + break; + case BluetoothLeScanSettings.SCAN_MODE_BALANCED: + this.scanWindow = SCAN_MODE_BALANCED_WINDOW_MS; + this.scanInterval = SCAN_MODE_BALANCED_INTERVAL_MS; + break; + case BluetoothLeScanSettings.SCAN_MODE_LOW_LATENCY: + this.scanWindow = SCAN_MODE_LOW_LATENCY_WINDOW_MS; + this.scanInterval = SCAN_MODE_LOW_LATENCY_INTERVAL_MS; + break; + default: + this.scanWindow = SCAN_MODE_BALANCED_WINDOW_MS; + this.scanInterval = SCAN_MODE_BALANCED_INTERVAL_MS; + break; + } + } } } -- 2.11.0