From ab1a7064d763ea40edfd65da977ec10ac0a58621 Mon Sep 17 00:00:00 2001 From: Uriel Lizama Date: Fri, 19 Aug 2016 16:52:37 -0500 Subject: [PATCH] Option to filter by service UUID when starting a scan --- .../lmbluetoothsdk/BluetoothLEController.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lmbluetoothsdk/src/main/java/co/lujun/lmbluetoothsdk/BluetoothLEController.java b/lmbluetoothsdk/src/main/java/co/lujun/lmbluetoothsdk/BluetoothLEController.java index fa2755a..77bdd83 100755 --- a/lmbluetoothsdk/src/main/java/co/lujun/lmbluetoothsdk/BluetoothLEController.java +++ b/lmbluetoothsdk/src/main/java/co/lujun/lmbluetoothsdk/BluetoothLEController.java @@ -121,7 +121,7 @@ public boolean isSupportBLE(){ } @Override - public boolean startScan() { + public boolean startScan(UUID[] serviceUUIDs) { if (!isAvailable() && !isEnabled()){ return false; } @@ -130,12 +130,23 @@ public boolean startScan() { mLeSettings = new ScanSettings.Builder() .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY) .build(); - mLeFilters = new ArrayList(); + mLeFilters = scanFilters(serviceUUIDs); } scanLeDevice(); return true; } + private List scanFilters(UUID[] serviceUUIDs) { + List list = new ArrayList<>(); + + for (int i = 0; i