Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Android BLE SCAN_FAILED_FEATURE_UNSUPPORTED on Nexus 5?

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

like image 799
4ntoine Avatar asked Feb 07 '23 19:02

4ntoine


1 Answers

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.

like image 98
BayssMekanique Avatar answered Feb 11 '23 01:02

BayssMekanique