From e9fd4cb7dca13c01f85ad63b667100ee15d7dc6d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 27 Apr 2018 15:04:50 -0700 Subject: [PATCH] Android: correctly detect the different BT device types The previous code would not add the non-LE address for dual stack devices. Unfortunately, even with this fix we still don't get the correct result for the dual stack Shearwater Petrel 2 that I have for testing as Android incorrectly reports it as a BLE-only device. Signed-off-by: Dirk Hohndel --- core/btdiscovery.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp index 5fa6a7c80..1848b8442 100644 --- a/core/btdiscovery.cpp +++ b/core/btdiscovery.cpp @@ -247,15 +247,16 @@ void BTDiscovery::getBluetoothDevices() continue; } jint btType = dev.callMethod("getType", "()I"); + // 1 means Classic. 2 means BLE, 3 means dual stack result.address = dev.callObjectMethod("getAddress","()Ljava/lang/String;").toString(); - if (btType == 2) // DEVICE_TYPE_LE - result.address = QString("LE:%1").arg(result.address); result.name = dev.callObjectMethod("getName", "()Ljava/lang/String;").toString(); - qDebug() << "paired Device type" << btType << "with address" << result.address; - btPairedDevices.append(result); - if (btType == 3) { // DEVICE_TYPE_DUAL + if (btType & 1) { // DEVICE_TYPE_CLASSIC + qDebug() << "paired BT classic device type" << btType << "with address" << result.address; + btPairedDevices.append(result); + } + if (btType & 2) { // DEVICE_TYPE_LE result.address = QString("LE:%1").arg(result.address); - qDebug() << "paired Device type" << btType << "with address" << result.address; + qDebug() << "paired BLE device type" << btType << "with address" << result.address; btPairedDevices.append(result); } }