summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycontroller.cpp
diff options
context:
space:
mode:
authorNedim Hadzic <nhadzic@blackberry.com>2014-02-19 15:59:53 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-21 22:57:03 +0100
commitcdc3ee8b00380ad208561e6c9bf575762fa398fb (patch)
tree768f63e371bdfd914943307d9b330d612d7a3329 /src/bluetooth/qlowenergycontroller.cpp
parentf9a28bc6009d3f0eecc65df9da75faa8c4133fcf (diff)
Renaming QLowEnergyServiceInfo methods
Ensures that QLowEnergyServiceInfo and QBluetoothServiceInfo are more alike. Tests and examples updated as well. Change-Id: I0f6a97900891a9673f99578bdc8d156a8c403513 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller.cpp')
-rw-r--r--src/bluetooth/qlowenergycontroller.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/bluetooth/qlowenergycontroller.cpp b/src/bluetooth/qlowenergycontroller.cpp
index 2dbd1a87..e2ca99cc 100644
--- a/src/bluetooth/qlowenergycontroller.cpp
+++ b/src/bluetooth/qlowenergycontroller.cpp
@@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE
This signal is emitted when the service error occurs.
- \sa QLowEnergyServiceInfo::errorString()
+ \sa errorString()
*/
/*!
@@ -91,7 +91,7 @@ QT_BEGIN_NAMESPACE
This signal is emitted when the characteristic error occurs.
- \sa QLowEnergyCharacteristicInfo::errorString()
+ \sa errorString()
*/
/*!
@@ -123,7 +123,7 @@ QLowEnergyControllerPrivate::~QLowEnergyControllerPrivate()
void QLowEnergyControllerPrivate::_q_serviceConnected(const QBluetoothUuid &uuid)
{
for (int i = 0; i < m_leServices.size(); i++) {
- if (((QLowEnergyServiceInfo)m_leServices.at(i)).uuid() == uuid)
+ if (((QLowEnergyServiceInfo)m_leServices.at(i)).serviceUuid() == uuid)
emit q_ptr->connected((QLowEnergyServiceInfo)m_leServices.at(i));
}
@@ -132,8 +132,11 @@ void QLowEnergyControllerPrivate::_q_serviceConnected(const QBluetoothUuid &uuid
void QLowEnergyControllerPrivate::_q_serviceError(const QBluetoothUuid &uuid)
{
for (int i = 0; i < m_leServices.size(); i++) {
- if (((QLowEnergyServiceInfo)m_leServices.at(i)).uuid() == uuid)
- emit q_ptr->error((QLowEnergyServiceInfo)m_leServices.at(i));
+ if (((QLowEnergyServiceInfo)m_leServices.at(i)).serviceUuid() == uuid) {
+ QLowEnergyServiceInfo service((QLowEnergyServiceInfo)m_leServices.at(i));
+ errorString = service.d_ptr->errorString;
+ emit q_ptr->error(service);
+ }
}
}
@@ -142,8 +145,10 @@ void QLowEnergyControllerPrivate::_q_characteristicError(const QBluetoothUuid &u
for (int i = 0; i < m_leServices.size(); i++) {
QList<QLowEnergyCharacteristicInfo> characteristics = m_leServices.at(i).characteristics();
for (int j = 0; j < characteristics.size(); j++) {
- if (characteristics.at(j).uuid() == uuid)
+ if (characteristics.at(j).uuid() == uuid) {
+ errorString = characteristics.at(j).d_ptr->errorString;
emit q_ptr->error(characteristics.at(j));
+ }
}
}
}
@@ -165,7 +170,7 @@ void QLowEnergyControllerPrivate::_q_valueReceived(const QBluetoothUuid &uuid)
void QLowEnergyControllerPrivate::_q_serviceDisconnected(const QBluetoothUuid &uuid)
{
for (int i = 0; i < m_leServices.size(); i++) {
- if (((QLowEnergyServiceInfo)m_leServices.at(i)).uuid() == uuid) {
+ if (((QLowEnergyServiceInfo)m_leServices.at(i)).serviceUuid() == uuid) {
QObject::disconnect(((QLowEnergyServiceInfo)m_leServices.at(i)).d_ptr.data(), SIGNAL(connectedToService(QBluetoothUuid)), q_ptr, SLOT(_q_serviceConnected(QBluetoothUuid)));
QObject::disconnect(((QLowEnergyServiceInfo)m_leServices.at(i)).d_ptr.data(), SIGNAL(error(QBluetoothUuid)), q_ptr, SLOT(_q_serviceError(QBluetoothUuid)));
QObject::disconnect(((QLowEnergyServiceInfo)m_leServices.at(i)).d_ptr.data(), SIGNAL(disconnectedFromService(QBluetoothUuid)), q_ptr, SLOT(_q_serviceDisconnected(QBluetoothUuid)));
@@ -179,7 +184,7 @@ void QLowEnergyControllerPrivate::connectService(const QLowEnergyServiceInfo &se
bool in = false;
if (service.isValid()) {
for (int i = 0; i < m_leServices.size(); i++) {
- if (((QLowEnergyServiceInfo)m_leServices.at(i)).uuid() == service.uuid() && !((QLowEnergyServiceInfo)m_leServices.at(i)).isConnected()) {
+ if (((QLowEnergyServiceInfo)m_leServices.at(i)).serviceUuid() == service.serviceUuid() && !((QLowEnergyServiceInfo)m_leServices.at(i)).isConnected()) {
in = true;
QObject::connect(m_leServices.at(i).d_ptr.data(), SIGNAL(connectedToService(QBluetoothUuid)), q_ptr, SLOT(_q_serviceConnected(QBluetoothUuid)));
QObject::connect(((QLowEnergyServiceInfo)m_leServices.at(i)).d_ptr.data(), SIGNAL(error(QBluetoothUuid)), q_ptr, SLOT(_q_serviceError(QBluetoothUuid)));
@@ -202,7 +207,7 @@ void QLowEnergyControllerPrivate::disconnectService(const QLowEnergyServiceInfo
{
if (service.isValid()) {
for (int i = 0; i < m_leServices.size(); i++) {
- if (((QLowEnergyServiceInfo)m_leServices.at(i)).uuid() == service.uuid() && service.isConnected()) {
+ if (((QLowEnergyServiceInfo)m_leServices.at(i)).serviceUuid() == service.serviceUuid() && service.isConnected()) {
((QLowEnergyServiceInfo)m_leServices.at(i)).d_ptr->unregisterServiceWatcher();
break;
}
@@ -301,4 +306,14 @@ void QLowEnergyController::disableNotifications(const QLowEnergyCharacteristicIn
}
}
}
+
+/*!
+ Returns a human-readable description of the last error that occurred.
+
+ \sa error(const QLowEnergyServiceInfo &), error(const QLowEnergyCharacteristicInfo &)
+*/
+QString QLowEnergyController::errorString() const
+{
+ return d_ptr->errorString;
+}
QT_END_NAMESPACE