BluetoothAdapter.startScan () and BluetoothAdapter.startLeScan ()

My goal is to find neighboring Bluetooth devices (LE and "Classic" devices) to associate existing visible neighboring devices with some of the features that my application does with it. (not a specific device / devices, but all of them !!!)

what i know:

  • startLeScan() will callback only with BLE devices
  • the two methods work differently - while startBLeScan () is controlled by my code with callbacks, while the classic scan is controlled by the system process and returns the BluetoothDevice found through the broadcasts.

what i don't know for sure:

  • startScan() current API level of the device is 18+ startScan() , there will always be both available BLEs and classic devices.
  • BluetoothDevice.connectGatt() a new BLE API has been added, but it should also work with classic bluetooth (return GATT services ...).

What I would like to know:

  • if startScan() really returns both types (classic and BLE), what is better to use in terms of battery consumption, performance, best practices and other aspects?

my application will periodically perform background scans, so I would like to minimize the impact of battery consumption.

+7
android android bluetooth bluetooth-lowenergy
source share
2 answers

You need to start scanning for classic Bluetooth devices with startDiscovery () and scanning for Bluetooth LE devices with startLeScan () . Attention! Performing device discovery is a tough procedure for a Bluetooth adapter and consumes a lot of resources.

Edit: On the LG Nexus 4 with Android 4.4.2, startDiscovery () finds Bluetooth LE devices. On Samsung Galaxy S3 with Android 4.3, startDiscovery () does not find a Bluetooth LE device.

+3
source share

I have a non-working Chinese tablet with BLE support, however it always returns a BLE equipped device called "null" when I call startLeScan. The problem was resolved by calling startDiscovery. Remember that if your application targets 23 or higher, you will need to have permissions for startDiscovery to work properly. Hope this helps.

0
source share

All Articles