From ec4aa0bcb592e9668b0767906157a1a51915d76c Mon Sep 17 00:00:00 2001 From: Nedim Hadzic Date: Thu, 20 Mar 2014 12:08:08 +0100 Subject: Added and improved error handling in controller class Error enums added and implemented together with examples. Change-Id: I912c396080ee9a6b87f41104eb7e41f8c62abf8b Reviewed-by: Alex Blasche --- examples/bluetooth/lowenergyscanner/device.cpp | 7 ++++--- examples/bluetooth/lowenergyscanner/device.h | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'examples/bluetooth/lowenergyscanner') diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp index 44cd3512..d137fd40 100644 --- a/examples/bluetooth/lowenergyscanner/device.cpp +++ b/examples/bluetooth/lowenergyscanner/device.cpp @@ -152,7 +152,8 @@ void Device::scanServices(QString address) // Connecting signals and slots for connecting to LE services. info = new QLowEnergyController(); connect(info, SIGNAL(connected(QLowEnergyServiceInfo)), this, SLOT(serviceConnected(QLowEnergyServiceInfo))); - connect(info, SIGNAL(error(QLowEnergyServiceInfo)), this, SLOT(errorReceived(QLowEnergyServiceInfo))); + connect(info, SIGNAL(error(QLowEnergyServiceInfo, QLowEnergyCOntroller::Error)), + this, SLOT(errorReceived(QLowEnergyServiceInfo,QLowEnergyCOntroller::Error))); connect(info, SIGNAL(disconnected(QLowEnergyServiceInfo)), this, SLOT(serviceDisconnected(QLowEnergyServiceInfo))); } } @@ -195,9 +196,9 @@ void Device::serviceConnected(const QLowEnergyServiceInfo &service) emit characteristicsDone(); } -void Device::errorReceived(const QLowEnergyServiceInfo &service) +void Device::errorReceived(const QLowEnergyServiceInfo &service, QLowEnergyController::Error error) { - qWarning() << "Error: " << info->errorString() << service.serviceUuid(); + qWarning() << "Error: " << info->errorString() << service.serviceUuid() << error; setUpdate(info->errorString()); } diff --git a/examples/bluetooth/lowenergyscanner/device.h b/examples/bluetooth/lowenergyscanner/device.h index 307b0fb9..3ac28c8f 100644 --- a/examples/bluetooth/lowenergyscanner/device.h +++ b/examples/bluetooth/lowenergyscanner/device.h @@ -49,6 +49,7 @@ #include #include #include "deviceinfo.h" +#include "qlowenergycontroller.h" #include "qlowenergyserviceinfo.h" #include "serviceinfo.h" #include "characteristicinfo.h" @@ -56,7 +57,6 @@ QT_FORWARD_DECLARE_CLASS (QBluetoothDeviceInfo) QT_FORWARD_DECLARE_CLASS (QLowEnergyServiceInfo) QT_FORWARD_DECLARE_CLASS (QLowEnergyCharacteristicInfo) -QT_FORWARD_DECLARE_CLASS (QLowEnergyController) QT_FORWARD_DECLARE_CLASS (QBluetoothServiceInfo) class Device: public QObject @@ -86,7 +86,7 @@ public slots: void serviceScanDone(); void serviceConnected(const QLowEnergyServiceInfo &service); void connectToService(const QString &uuid); - void errorReceived(const QLowEnergyServiceInfo &service); + void errorReceived(const QLowEnergyServiceInfo &service, QLowEnergyController::Error); void disconnectFromService(); void serviceDisconnected(const QLowEnergyServiceInfo &service); void serviceScanError(QBluetoothServiceDiscoveryAgent::Error); -- cgit v1.2.3