Question

The android documentation states:

Note: You can only scan for Bluetooth LE devices or scan for Classic Bluetooth devices, as described in Bluetooth. You cannot scan for both Bluetooth LE and classic devices at the same time.

However I am noticing that calling mBtAdapter.startDiscovery(); is returning both classic and btle devices. Does anybody know what is correct here?

Was it helpful?

Solution

From my understanding what the documentation means is that you cannot have a startLeScan() and a startDiscovery() running at the same time. The reason might be that there is only one BluetoothAdapter object (the object that represents the local Bluetooth hardware) therefor it cannot do two different operations that use the BluetoothAdapter at the same time.(If someone knows anything different as to how it works in the background, let us know)

startLeScan() -> scans only for BLE devices
startDiscovery() -> discovers all Bluetooth devices, also it only scans for 12 seconds and this cannot be changed (have a read through the method description)

Note: After doing a startDiscovery() inquiry scan when a BT device is found you can get the device type to identify what each device is, For example:

    int deviceType = device.getType();

    if(deviceType == BluetoothDevice.DEVICE_TYPE_CLASSIC)
    {

    }
    else if(deviceType == BluetoothDevice.DEVICE_TYPE_LE)
    {

    }
    else if(deviceType == BluetoothDevice.DEVICE_TYPE_DUAL)
    {   

    }
    else if(deviceType == BluetoothDevice.DEVICE_TYPE_UNKNOWN)
    {

    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top