diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp index 2ff91a007..583c8541e 100644 --- a/core/btdiscovery.cpp +++ b/core/btdiscovery.cpp @@ -192,7 +192,11 @@ void BTDiscovery::BTDiscoveryReDiscover() connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &BTDiscovery::btDeviceDiscovered); connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &BTDiscovery::btDeviceDiscoveryFinished); connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::canceled, this, &BTDiscovery::btDeviceDiscoveryFinished); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::errorOccurred, +#else connect(discoveryAgent, QOverload::of(&QBluetoothDeviceDiscoveryAgent::error), +#endif [this](QBluetoothDeviceDiscoveryAgent::Error error){ qDebug() << "device discovery received error" << discoveryAgent->errorString(); }); diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp index 77afca821..ee951ffd7 100644 --- a/core/qt-ble.cpp +++ b/core/qt-ble.cpp @@ -110,7 +110,7 @@ static const char *match_uuid_list(const QBluetoothUuid &match, const struct uui const char *uuid; while ((uuid = array->uuid) != NULL) { - if (match == QUuid(uuid)) + if (match == QBluetoothUuid(QUuid(uuid))) return array->details; array++; } @@ -220,7 +220,11 @@ void BLEObject::addService(const QBluetoothUuid &newService) service->connect(service, &QLowEnergyService::stateChanged,[=](QLowEnergyService::ServiceState newState) { qDebug() << " .. service state changed to" << newState; }); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + service->connect(service, &QLowEnergyService::errorOccurred, +#else service->connect(service, QOverload::of(&QLowEnergyService::error), +#endif [=](QLowEnergyService::ServiceError newError) { qDebug() << "error discovering service details" << newError; }); @@ -393,8 +397,13 @@ dc_status_t BLEObject::select_preferred_service(void) { // Wait for each service to finish discovering foreach (const QLowEnergyService *s, services) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + WAITFOR(s->state() != QLowEnergyService::RemoteServiceDiscovering, BLE_TIMEOUT); + if (s->state() == QLowEnergyService::RemoteServiceDiscovering) +#else WAITFOR(s->state() != QLowEnergyService::DiscoveringServices, BLE_TIMEOUT); if (s->state() == QLowEnergyService::DiscoveringServices) +#endif qDebug() << " .. service " << s->serviceUuid() << "still hasn't completed discovery - trouble ahead"; } @@ -412,7 +421,11 @@ dc_status_t BLEObject::select_preferred_service(void) // Pick the preferred one foreach (QLowEnergyService *s, services) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (s->state() != QLowEnergyService::RemoteServiceDiscovered) +#else if (s->state() != QLowEnergyService::ServiceDiscovered) +#endif continue; bool hasread = false; @@ -604,7 +617,11 @@ dc_status_t qt_ble_open(void **io, dc_context_t *, const char *devaddr, device_d ble->addService(s); } }); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + ble->connect(controller, &QLowEnergyController::errorOccurred, [=](QLowEnergyController::Error newError) { +#else ble->connect(controller, QOverload::of(&QLowEnergyController::error), [=](QLowEnergyController::Error newError) { +#endif qDebug() << "controler discovery error" << controller->errorString() << newError; }); diff --git a/core/qt-ble.h b/core/qt-ble.h index f16f5b72c..b7e2cfcf7 100644 --- a/core/qt-ble.h +++ b/core/qt-ble.h @@ -60,16 +60,16 @@ private: unsigned int desc_written = 0; int timeout; - QList telit = { - "{00000001-0000-1000-8000-008025000000}", // TELIT_DATA_RX - "{00000002-0000-1000-8000-008025000000}", // TELIT_DATA_TX - "{00000003-0000-1000-8000-008025000000}", // TELIT_CREDITS_RX - "{00000004-0000-1000-8000-008025000000}" // TELIT_CREDITS_TX + QList telit = { + QBluetoothUuid(QUuid("{00000001-0000-1000-8000-008025000000}")), // TELIT_DATA_RX + QBluetoothUuid(QUuid("{00000002-0000-1000-8000-008025000000}")), // TELIT_DATA_TX + QBluetoothUuid(QUuid("{00000003-0000-1000-8000-008025000000}")), // TELIT_CREDITS_RX + QBluetoothUuid(QUuid("{00000004-0000-1000-8000-008025000000}")) // TELIT_CREDITS_TX }; - QList ublox = { - "{2456e1b9-26e2-8f83-e744-f34f01e9d703}", // UBLOX_DATA_RX, UBLOX_DATA_TX - "{2456e1b9-26e2-8f83-e744-f34f01e9d704}" // UBLOX_CREDITS_RX, UBLOX_CREDITS_TX + QList ublox = { + QBluetoothUuid(QUuid("{2456e1b9-26e2-8f83-e744-f34f01e9d703}")), // UBLOX_DATA_RX, UBLOX_DATA_TX + QBluetoothUuid(QUuid("{2456e1b9-26e2-8f83-e744-f34f01e9d704}")) // UBLOX_CREDITS_RX, UBLOX_CREDITS_TX }; }; diff --git a/desktop-widgets/btdeviceselectiondialog.cpp b/desktop-widgets/btdeviceselectiondialog.cpp index e54e78e20..650d3bf7c 100644 --- a/desktop-widgets/btdeviceselectiondialog.cpp +++ b/desktop-widgets/btdeviceselectiondialog.cpp @@ -473,11 +473,16 @@ void BtDeviceSelectionDialog::updateLocalDeviceInformation() ui->discoveredDevicesList->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->discoveredDevicesList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayPairingMenu(QPoint))); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + connect(localDevice, &QBluetoothLocalDevice::pairingFinished, this, &BtDeviceSelectionDialog::pairingFinished); + connect(localDevice, &QBluetoothLocalDevice::errorOccurred, this, &BtDeviceSelectionDialog::error); +#else connect(localDevice, SIGNAL(pairingFinished(QBluetoothAddress, QBluetoothLocalDevice::Pairing)), this, SLOT(pairingFinished(QBluetoothAddress, QBluetoothLocalDevice::Pairing))); connect(localDevice, SIGNAL(error(QBluetoothLocalDevice::Error)), this, SLOT(error(QBluetoothLocalDevice::Error))); +#endif } void BtDeviceSelectionDialog::initializeDeviceDiscoveryAgent() @@ -494,10 +499,19 @@ void BtDeviceSelectionDialog::initializeDeviceDiscoveryAgent() ui->clear->setEnabled(false); return; } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + connect(remoteDeviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, + this, &BtDeviceSelectionDialog::addRemoteDevice); + connect(remoteDeviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, + this, &BtDeviceSelectionDialog::remoteDeviceScanFinished); + connect(remoteDeviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::errorOccurred, + this, &BtDeviceSelectionDialog::deviceDiscoveryError); +#else connect(remoteDeviceDiscoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this, SLOT(addRemoteDevice(QBluetoothDeviceInfo))); connect(remoteDeviceDiscoveryAgent, SIGNAL(finished()), this, SLOT(remoteDeviceScanFinished())); connect(remoteDeviceDiscoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this, SLOT(deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error))); +#endif }