summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlowenergycontroller-gattserver
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@theqtcompany.com>2016-01-12 12:22:11 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2016-01-18 07:46:35 +0000
commite94fe90e7d2e1df9bd7d1d014fb468e5e73da834 (patch)
tree440a4e0359661b6cc4ac2e95455475ff0d64ebcd /tests/auto/qlowenergycontroller-gattserver
parent1046db1a91f264db6714975daa27f56a457a6778 (diff)
Bluetooth LE: Add connection update functionality.
Implemented for BlueZ only. Change-Id: I358a98bbc7499d5ce5437fb0d4672fde46c3b831 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests/auto/qlowenergycontroller-gattserver')
-rw-r--r--tests/auto/qlowenergycontroller-gattserver/server/qlowenergycontroller-gattserver.cpp6
-rw-r--r--tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp27
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qlowenergycontroller-gattserver/server/qlowenergycontroller-gattserver.cpp b/tests/auto/qlowenergycontroller-gattserver/server/qlowenergycontroller-gattserver.cpp
index e2c930bf..087b0284 100644
--- a/tests/auto/qlowenergycontroller-gattserver/server/qlowenergycontroller-gattserver.cpp
+++ b/tests/auto/qlowenergycontroller-gattserver/server/qlowenergycontroller-gattserver.cpp
@@ -33,6 +33,7 @@
#include <QtBluetooth/qlowenergyadvertisingdata.h>
#include <QtBluetooth/qlowenergyadvertisingparameters.h>
+#include <QtBluetooth/qlowenergyconnectionparameters.h>
#include <QtBluetooth/qlowenergycontroller.h>
#include <QtBluetooth/qlowenergycharacteristicdata.h>
#include <QtBluetooth/qlowenergydescriptordata.h>
@@ -212,6 +213,11 @@ int main(int argc, char *argv[])
Q_ASSERT(notifiableChar.isValid());
customService->writeCharacteristic(notifiableChar, "notified");
Q_ASSERT(notifiableChar.value() == "notified");
+ QLowEnergyConnectionParameters connParams;
+ connParams.setIntervalRange(30, 62.5);
+ connParams.setLatency(5);
+ connParams.setSupervisionTimeout(5500);
+ leController->requestConnectionUpdate(connParams);
};
QObject::connect(customService.data(), &QLowEnergyService::descriptorWritten,
descriptorWriteHandler);
diff --git a/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp b/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp
index 6c45eed7..e2534a14 100644
--- a/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp
+++ b/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp
@@ -37,6 +37,7 @@
#include <QtBluetooth/qbluetoothlocaldevice.h>
#include <QtBluetooth/qlowenergyadvertisingdata.h>
#include <QtBluetooth/qlowenergyadvertisingparameters.h>
+#include <QtBluetooth/qlowenergyconnectionparameters.h>
#include <QtBluetooth/qlowenergycontroller.h>
#include <QtBluetooth/qlowenergycharacteristicdata.h>
#include <QtBluetooth/qlowenergydescriptordata.h>
@@ -60,6 +61,7 @@ private slots:
// Static, local stuff goes here.
void advertisingParameters();
void advertisingData();
+ void connectionParameters();
void controllerType();
void serviceData();
@@ -148,6 +150,28 @@ void TestQLowEnergyControllerGattServer::advertisingData()
QVERIFY(data != QLowEnergyAdvertisingData());
}
+void TestQLowEnergyControllerGattServer::connectionParameters()
+{
+ QLowEnergyConnectionParameters connParams;
+ QCOMPARE(connParams, QLowEnergyConnectionParameters());
+ connParams.setIntervalRange(8, 9);
+ QCOMPARE(connParams.minimumInterval(), double(8));
+ QCOMPARE(connParams.maximumInterval(), double(9));
+ connParams.setIntervalRange(9, 8);
+ QCOMPARE(connParams.minimumInterval(), double(9));
+ QCOMPARE(connParams.maximumInterval(), double(9));
+ connParams.setLatency(50);
+ QCOMPARE(connParams.latency(), 50);
+ connParams.setSupervisionTimeout(1000);
+ QCOMPARE(connParams.supervisionTimeout(), 1000);
+ const QLowEnergyConnectionParameters cp2 = connParams;
+ QCOMPARE(cp2, connParams);
+ QLowEnergyConnectionParameters cp3;
+ QVERIFY(cp3 != connParams);
+ cp3 = connParams;
+ QCOMPARE(cp3, connParams);
+}
+
void TestQLowEnergyControllerGattServer::advertisedData()
{
if (m_serverAddress.isNull())
@@ -325,6 +349,9 @@ void TestQLowEnergyControllerGattServer::serverCommunication()
QCOMPARE(customChar3.value().constData(), "indicated");
QCOMPARE(customChar4.value().constData(), "notified");
+ spy.reset(new QSignalSpy(m_leController.data(), &QLowEnergyController::connectionUpdated));
+ QVERIFY(spy->wait(5000));
+
const bool isBonded = QBluetoothLocalDevice().pairingStatus(m_serverAddress)
!= QBluetoothLocalDevice::Unpaired;
m_leController->disconnectFromDevice();