diff options
author | Nedim Hadzic <nhadzic@blackberry.com> | 2013-10-23 17:33:36 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2013-11-04 09:35:01 +0100 |
commit | ec61d7b9e82e6d653c02df14f34acdba8fc060db (patch) | |
tree | d61e73318c11e0dcae471ee7c1f8ed56397b9f75 /examples | |
parent | b00388ea1448cfd977c54f53d038d1a270562d53 (diff) |
Implemented Bluetooth Low Energy gatt service and characteristics discovery
Bluez v4.x does not have total support for LE devices, a new approach, using gatttool command was implemented.
Auto-tests and documentation will be in other commits.
Change-Id: Iee711cc111199e15956052eebb7593bd3a5e27c8
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/bluetooth/btchat/chatserver.cpp | 2 | ||||
-rw-r--r-- | examples/bluetooth/btscanner/service.cpp | 13 | ||||
-rw-r--r-- | examples/bluetooth/btscanner/service.h | 3 |
3 files changed, 18 insertions, 0 deletions
diff --git a/examples/bluetooth/btchat/chatserver.cpp b/examples/bluetooth/btchat/chatserver.cpp index 0b29b87b..6da4b471 100644 --- a/examples/bluetooth/btchat/chatserver.cpp +++ b/examples/bluetooth/btchat/chatserver.cpp @@ -83,7 +83,9 @@ void ChatServer::startServer(const QBluetoothAddress& localAdapter) classId); classId.prepend(QVariant::fromValue(QBluetoothUuid(serviceUuid))); + serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId); + serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList,classId); //! [Class Uuuid must contain at least 1 entry] diff --git a/examples/bluetooth/btscanner/service.cpp b/examples/bluetooth/btscanner/service.cpp index dedd3770..c1db7cce 100644 --- a/examples/bluetooth/btscanner/service.cpp +++ b/examples/bluetooth/btscanner/service.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 BlackBerry Limited. All rights reserved. ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. @@ -44,6 +45,9 @@ #include <qbluetoothservicediscoveryagent.h> #include <qbluetoothserviceinfo.h> #include <qbluetoothlocaldevice.h> +#include <qlowenergyserviceinfo.h> +#include <qlowenergycharacteristicinfo.h> +#include <qbluetoothuuid.h> ServiceDiscoveryDialog::ServiceDiscoveryDialog(const QString &name, @@ -74,6 +78,8 @@ ServiceDiscoveryDialog::ServiceDiscoveryDialog(const QString &name, connect(discoveryAgent, SIGNAL(serviceDiscovered(const QBluetoothServiceInfo&)), this, SLOT(addService(const QBluetoothServiceInfo&))); connect(discoveryAgent, SIGNAL(finished()), ui->status, SLOT(hide())); + connect(discoveryAgent, SIGNAL(serviceDiscovered(const QLowEnergyServiceInfo&)), + this, SLOT(addLowEnergyService(const QLowEnergyServiceInfo&))); discoveryAgent->start(); } @@ -98,3 +104,10 @@ void ServiceDiscoveryDialog::addService(const QBluetoothServiceInfo &info) ui->list->addItem(line); } +void ServiceDiscoveryDialog::addLowEnergyService(const QLowEnergyServiceInfo &gatt) +{ + QString line = gatt.name(); + + ui->list->addItem(line); +} + diff --git a/examples/bluetooth/btscanner/service.h b/examples/bluetooth/btscanner/service.h index 293bc7a9..2089eb87 100644 --- a/examples/bluetooth/btscanner/service.h +++ b/examples/bluetooth/btscanner/service.h @@ -49,6 +49,8 @@ QT_FORWARD_DECLARE_CLASS(QBluetoothAddress) QT_FORWARD_DECLARE_CLASS(QBluetoothServiceInfo) QT_FORWARD_DECLARE_CLASS(QBluetoothServiceDiscoveryAgent) +QT_FORWARD_DECLARE_CLASS (QLowEnergyServiceInfo) +QT_FORWARD_DECLARE_CLASS (QLowEnergyCharacteristicInfo) QT_USE_NAMESPACE @@ -62,6 +64,7 @@ public: public slots: void addService(const QBluetoothServiceInfo&); + void addLowEnergyService(const QLowEnergyServiceInfo&); private: QBluetoothServiceDiscoveryAgent *discoveryAgent; |