diff options
author | 2017-09-17 15:40:16 -0700 | |
---|---|---|
committer | 2017-09-17 15:40:16 -0700 | |
commit | ae209a3d9f8ed36e2228834d421ff4a6ac345ad9 (patch) | |
tree | 046937d0c944d3b6ad8ff9a8c49ab8bdcc3136d9 /core/qt-ble.cpp | |
parent | 58b7c6f8ef703009e098351774b8db521cce48e3 (diff) | |
parent | 49fe120d9530682cf539d562c4ffcae3e195b9ab (diff) | |
download | subsurface-ae209a3d9f8ed36e2228834d421ff4a6ac345ad9.tar.gz |
Merge branch 'macBLE' of github.com:Subsurface-divelog/subsurface
Diffstat (limited to 'core/qt-ble.cpp')
-rw-r--r-- | core/qt-ble.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp index 9867528c8..92a78ae65 100644 --- a/core/qt-ble.cpp +++ b/core/qt-ble.cpp @@ -16,6 +16,7 @@ #include "libdivecomputer.h" #include "core/qt-ble.h" +#include "core/btdiscovery.h" #if defined(SSRF_CUSTOM_IO) @@ -287,12 +288,11 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d if (!strncmp(devaddr, "LE:", 3)) devaddr += 3; - QBluetoothAddress remoteDeviceAddress(devaddr); - // HACK ALERT! Qt 5.9 needs this for proper Bluez operation qputenv("QT_DEFAULT_CENTRAL_SERVICES", "1"); - QLowEnergyController *controller = new QLowEnergyController(remoteDeviceAddress); + QBluetoothDeviceInfo remoteDevice = getBtDeviceInfo(devaddr); + QLowEnergyController *controller = QLowEnergyController::createCentral(remoteDevice); qDebug() << "qt_ble_open(" << devaddr << ")"; @@ -382,8 +382,19 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d qDebug() << "Descriptor:" << d.name() << "uuid:" << d.uuid().toString(); if (!l.isEmpty()) { - d = l.first(); - qDebug() << "now writing \"0x0100\" to the first descriptor"; + bool foundCCC = false; + foreach (d, l) { + if (d.type() == QBluetoothUuid::ClientCharacteristicConfiguration) { + // pick the correct characteristic + foundCCC = true; + break; + } + } + if (!foundCCC) + // if we didn't find a ClientCharacteristicConfiguration, try the first one + d = l.first(); + + qDebug() << "now writing \"0x0100\" to the descriptor" << d.uuid().toString(); ble->preferredService()->writeDescriptor(d, QByteArray::fromHex("0100")); } |