mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
BLE: create controller from QBtDeviceInfo
Creating it from an address is a) deprecated and b) impossible on Mac or iOS. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
db38a7023d
commit
26e610c3f4
2 changed files with 6 additions and 4 deletions
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "libdivecomputer.h"
|
#include "libdivecomputer.h"
|
||||||
#include "core/qt-ble.h"
|
#include "core/qt-ble.h"
|
||||||
|
#include "core/btdiscovery.h"
|
||||||
|
|
||||||
#if defined(SSRF_CUSTOM_IO)
|
#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))
|
if (!strncmp(devaddr, "LE:", 3))
|
||||||
devaddr += 3;
|
devaddr += 3;
|
||||||
|
|
||||||
QBluetoothAddress remoteDeviceAddress(devaddr);
|
|
||||||
|
|
||||||
// HACK ALERT! Qt 5.9 needs this for proper Bluez operation
|
// HACK ALERT! Qt 5.9 needs this for proper Bluez operation
|
||||||
qputenv("QT_DEFAULT_CENTRAL_SERVICES", "1");
|
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 << ")";
|
qDebug() << "qt_ble_open(" << devaddr << ")";
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,9 @@ void BtDeviceSelectionDialog::on_save_clicked()
|
||||||
|
|
||||||
// Save the selected device
|
// Save the selected device
|
||||||
selectedRemoteDeviceInfo = QSharedPointer<QBluetoothDeviceInfo>(new QBluetoothDeviceInfo(remoteDeviceInfo));
|
selectedRemoteDeviceInfo = QSharedPointer<QBluetoothDeviceInfo>(new QBluetoothDeviceInfo(remoteDeviceInfo));
|
||||||
|
QString address = remoteDeviceInfo.address().isNull() ? remoteDeviceInfo.deviceUuid().toString() :
|
||||||
|
remoteDeviceInfo.address().toString();
|
||||||
|
saveBtDeviceInfo(address.toUtf8().constData(), remoteDeviceInfo);
|
||||||
if (remoteDeviceDiscoveryAgent->isActive()) {
|
if (remoteDeviceDiscoveryAgent->isActive()) {
|
||||||
// Stop the SDP agent if the clear button is pressed and enable the Scan button
|
// Stop the SDP agent if the clear button is pressed and enable the Scan button
|
||||||
remoteDeviceDiscoveryAgent->stop();
|
remoteDeviceDiscoveryAgent->stop();
|
||||||
|
|
Loading…
Add table
Reference in a new issue