-
Notifications
You must be signed in to change notification settings - Fork 107
LBluetoothLeScannerCompat fails to work when using ScanSettings.CALLBACK_TYPE_FIRST_MATCH | ScanSettings.CALLBACK_TYPE_MATCH_LOST #214
Comments
Do you have the correct permissions in the manifest? On Sat, Mar 7, 2015, 2:17 PM Simon GUEROUT [email protected] wrote:
|
Well, I have BLUETOOTH and BLUETOOTH_ADMIN, but as BLUETOOTH_PRIVILEGED is not supposed to be used, I did not include it at first.
Even including it does not change anything. Here is the code I am using scanner = BluetoothLeScannerCompatProvider.getBluetoothLeScannerCompat(mContext);
// THIS FAILS
scanner.startScan(
Arrays.asList(new ScanFilter.Builder().setServiceUuid(ParcelUuid.fromString("7265656c-7941-6374-6976-652055554944")).build()),
new ScanSettings.Builder() //
.setCallbackType(ScanSettings.CALLBACK_TYPE_FIRST_MATCH | ScanSettings.CALLBACK_TYPE_MATCH_LOST) //
.setScanMode(ScanSettings.SCAN_MODE_LOW_POWER) //
.setScanResultType(ScanSettings.SCAN_RESULT_TYPE_FULL) //
.build(),
scanCallback
);
// THIS WORKS
scanner.startScan(
Arrays.asList(new ScanFilter.Builder().setServiceUuid(ParcelUuid.fromString("7265656c-7941-6374-6976-652055554944")).build()),
new ScanSettings.Builder() //
.setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES) //
.setScanMode(ScanSettings.SCAN_MODE_LOW_POWER) //
.setScanResultType(ScanSettings.SCAN_RESULT_TYPE_FULL) //
.build(),
scanCallback
); |
Take a look at this. It seems there is one extra permission needed for the On Sat, Mar 7, 2015, 2:51 PM Simon GUEROUT [email protected] wrote:
|
The extra permission is not used in Lollipop, but it is in my Manifest. |
I am working on a project based on parts of this library : https://github.com/reelyactive/ble-android-sdk |
The compat library uses the ble lollipop library if available (where only On Sat, Mar 7, 2015, 3:19 PM Simon GUEROUT [email protected] wrote:
|
I tried using both versions of the API on hte Nexus 9 and using FIRST_MATCH|MATCH_LOST fails with the newest : // GO LOLLIPOP
scanner = BluetoothLeScannerCompatProvider.getBluetoothLeScannerCompat(mContext);
// GO JELLYBEAN
scanner = BluetoothLeScannerCompatProvider.getBluetoothLeScannerCompat(mContext, false); |
So the first one doesn't work but the second one does? On Sat, Mar 7, 2015, 3:28 PM Simon GUEROUT [email protected] wrote:
|
So I tried 4 cases:
In the JbBluetoothLeScannerCompat the adresses seen during the scan are kept in memory, in order to track events when using FIRST_MATCH|MATCH_LOST, in LBluetoothLeScannerCompat there is a call to if (method.toString().contains(".setCallbackType(")) {
method.invoke(builder, settings.getCallbackType());
callbackTypeSet = true;
} which leads to the error. In order to support FIRST_MATCH|MATCH_LOST, the same code as in JbBluetoothLeScannerCompat#callbackLeScanClients |
I am working on it. I will fix it within 10 days. I got the real issue I will fix it. for more information click scanner. |
I am running the code on a Nexus 9, with Android 5.0.1.
Scan fails to start with the following message :
I found out that the parameters are handled using reflection.
The only compatible setting is the CALLBACK_TYPE_ALL_MATCHES.
In my opinion we could fix the issue by :
I am working on a fix, and will probably post a reply about it.
The text was updated successfully, but these errors were encountered: