4

I'm having this onScanFailed error code on some devices (LG to be more detailed) when discovering BLE devices on android. The code works as expected on another devices. How can i fix it?

I use BLE API 21+ and the following code to discover:

ScanSettings scanSettings = new ScanSettings.Builder()
            .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
            .setReportDelay(discoveryDelay)
            .build();

Here are the full sources: https://github.com/4ntoine/protobuf-ble-rpc/blob/hi-p/android/client/src/main/java/com/googlecode/protobuf/blerpc/BleRpcConnectionFactory.java#L362

4
  • is your LG is pre lolipop? Feb 8, 2016 at 10:07
  • no, it's Marshmallow. But the app is targeted to pre-Marshmallow so it's not permissions issue
    – 4ntoine
    Feb 8, 2016 at 10:09
  • try like this way new ScanSettings.Builder().build() for scanSettings not sure but having same issue in android M Feb 8, 2016 at 10:12
  • getting the same error if commented .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
    – 4ntoine
    Feb 8, 2016 at 10:26

1 Answer 1

8

Some devices do not support all of the features of the new LE API. The features are hardware specific and up to the manufacturer to enable. The best approach is to check for the supported feature before building the filter and settings.

bluetoothAdapter.isOffloadedFilteringSupported();

bluetoothAdapter.isOffloadedScanBatchingSupported();

I haven't found any issues with issuing filters when OffloadedFiltering isn't supported.

If OffloadedScanBatching isn't supported, then you should not set a report delay. Attempting to set a report delay of anything other than 0 will result in an error.

6
  • that information is very helpful, going to check it
    – 4ntoine
    Feb 9, 2016 at 8:05
  • does http://developer.android.com/intl/ru/reference/android/bluetooth/le/ScanFilter.Builder.html#setServiceUuid(android.os.ParcelUuid) work only if isOffloadedFilteringSupported returns true ? it's not described in docs
    – 4ntoine
    Feb 9, 2016 at 8:12
  • confirmed to be working now, thanks. Fixed by avoiding system filtering if not supported and added self-made filtering
    – 4ntoine
    Feb 9, 2016 at 10:44
  • I haven't dug deep enough into the source to figure out what changes with the isOffloadedFilteringSupported, but I would assume it had to do with whether the filtering gets handed to the HAL to be filtered by the hardware during a scan, or if it's done on the higher level after the scan is complete. Feb 9, 2016 at 13:20
  • Samsung Galaxy Alpha (SM-G850W Android 5.0.2) reports isOffloadedScanBatchingSupported as true, but does not work when .setReportDelay(discoveryDelay) is set. Jun 6, 2016 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.