From 5ccf3e81eb3a0254a1f85fcbd9bd4c6ea3addcb1 Mon Sep 17 00:00:00 2001 From: Claudiu Olteanu Date: Sat, 18 Jul 2015 20:54:31 +0300 Subject: Log errors which occur during Bluetooth device discovery Register to the signal emmited when an error occurs during Bluetooth device discovery and log a description of the error which can be used to identify problem's cause. Signed-off-by: Claudiu Olteanu Signed-off-by: Dirk Hohndel --- qt-ui/btdeviceselectiondialog.cpp | 21 +++++++++++++++++++++ qt-ui/btdeviceselectiondialog.h | 1 + 2 files changed, 22 insertions(+) diff --git a/qt-ui/btdeviceselectiondialog.cpp b/qt-ui/btdeviceselectiondialog.cpp index 2f5a5d1f9..e52580e78 100644 --- a/qt-ui/btdeviceselectiondialog.cpp +++ b/qt-ui/btdeviceselectiondialog.cpp @@ -276,6 +276,25 @@ void BtDeviceSelectionDialog::error(QBluetoothLocalDevice::Error error) .arg((error == QBluetoothLocalDevice::PairingError)? "Pairing error" : "Unknown error")); } +void BtDeviceSelectionDialog::deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error error) +{ + QString errorDescription; + + switch (error) { + case QBluetoothDeviceDiscoveryAgent::PoweredOffError: + errorDescription = QString("The Bluetooth adaptor is powered off, power it on before doing discovery."); + break; + case QBluetoothDeviceDiscoveryAgent::InputOutputError: + errorDescription = QString("Writing or reading from the device resulted in an error."); + break; + default: + errorDescription = QString("An unknown error has occurred."); + break; + } + + ui->dialogStatus->setText(QString("Device discovery error: %1.").arg(errorDescription)); +} + QString BtDeviceSelectionDialog::getSelectedDeviceAddress() { if (selectedRemoteDeviceInfo) { @@ -336,4 +355,6 @@ void BtDeviceSelectionDialog::initializeDeviceDiscoveryAgent() this, SLOT(addRemoteDevice(QBluetoothDeviceInfo))); connect(remoteDeviceDiscoveryAgent, SIGNAL(finished()), this, SLOT(remoteDeviceScanFinished())); + connect(remoteDeviceDiscoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), + this, SLOT(deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error))); } diff --git a/qt-ui/btdeviceselectiondialog.h b/qt-ui/btdeviceselectiondialog.h index 9c040dc68..b6c34e8b8 100644 --- a/qt-ui/btdeviceselectiondialog.h +++ b/qt-ui/btdeviceselectiondialog.h @@ -37,6 +37,7 @@ private slots: void displayPairingMenu(const QPoint &pos); void pairingFinished(const QBluetoothAddress &address,QBluetoothLocalDevice::Pairing pairing); void error(QBluetoothLocalDevice::Error error); + void deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error error); void localDeviceChanged(int); private: -- cgit v1.2.3-70-g09d2