From 753c00a4936f5cc741bdf7dbeb3db83903a95e9d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 17 Sep 2017 16:31:07 -0700 Subject: [PATCH] BLE on non-Apple OSs: switch back to using BT address While this interface is deprecated, too much in our existing code depends on being able to create the QLowEnergyController with just the address. Additionally, createCentral() is new in Qt 5.7 and therefor this broke builds on Linux distros that are still on 5.6. Signed-off-by: Dirk Hohndel --- core/qt-ble.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp index 92a78ae65..01597d4b8 100644 --- a/core/qt-ble.cpp +++ b/core/qt-ble.cpp @@ -291,9 +291,17 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d // HACK ALERT! Qt 5.9 needs this for proper Bluez operation qputenv("QT_DEFAULT_CENTRAL_SERVICES", "1"); +#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) QBluetoothDeviceInfo remoteDevice = getBtDeviceInfo(devaddr); QLowEnergyController *controller = QLowEnergyController::createCentral(remoteDevice); - +#else + // this is deprecated but given that we don't use Qt to scan for + // devices on Android, we don't have QBluetoothDeviceInfo for the + // paired devices and therefore cannot use the newer interfaces + // that are preferred starting with Qt 5.7 + QBluetoothAddress remoteDeviceAddress(devaddr); + QLowEnergyController *controller = new QLowEnergyController(remoteDeviceAddress); +#endif qDebug() << "qt_ble_open(" << devaddr << ")"; if (IS_SHEARWATER(io->user_device))