diff options
Diffstat (limited to 'tests')
40 files changed, 3292 insertions, 623 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 5a703944..8966e5d9 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -16,7 +16,11 @@ qtHaveModule(bluetooth) { qbluetoothtransfermanager \ qbluetoothtransferrequest \ qbluetoothuuid \ - qbluetoothserver + qbluetoothserver \ + qlowenergycharacteristic \ + qlowenergydescriptor \ + qlowenergyserviceinfo \ + qlowenergycontroller } qtHaveModule(nfc) { diff --git a/tests/auto/qbluetoothaddress/tst_qbluetoothaddress.cpp b/tests/auto/qbluetoothaddress/tst_qbluetoothaddress.cpp index d53f39dd..171726b8 100644 --- a/tests/auto/qbluetoothaddress/tst_qbluetoothaddress.cpp +++ b/tests/auto/qbluetoothaddress/tst_qbluetoothaddress.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp index 2da1a8a9..ca22c8ea 100644 --- a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp +++ b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -250,13 +242,27 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries() QVERIFY(discoveryAgent.error() == discoveryAgent.NoError); QVERIFY(discoveryAgent.errorString().isEmpty()); + /* + Starting case 4: start-stop-start-stop: + We are testing that two subsequent stop() calls reduce total number + of cancel() signals to 1 if the true cancellation requires + asynchronous function calls (signal consolidation); otherwise we + expect 2x cancel() signal. - // Starting case 4: start-stop-start-stop, expecting only 1 cancel signal + Examples are: + - Bluez4 (event loop needs to run for cancel) + - Bluez5 (no event loop required) + */ + + bool immediateSignal = false; discoveryAgent.start(); QVERIFY(discoveryAgent.isActive()); QVERIFY(errorSpy.isEmpty()); // cancel current request. discoveryAgent.stop(); + //should only have triggered cancel() if stop didn't involve the event loop + if (cancelSpy.count() == 1) immediateSignal = true; + // start a new one discoveryAgent.start(); // we should be active now @@ -264,6 +270,8 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries() QVERIFY(errorSpy.isEmpty()); // stop discoveryAgent.stop(); + if (immediateSignal) + QVERIFY(cancelSpy.count() == 2); // Wait for up to MaxWaitForCancelTime for the cancel to finish waitTime = MaxWaitForCancelTime; @@ -271,12 +279,15 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries() QTest::qWait(100); waitTime-=100; } - // we should not be active anymore QVERIFY(!discoveryAgent.isActive()); QVERIFY(errorSpy.isEmpty()); // should only have 1 cancel - QVERIFY(cancelSpy.count() == 1); + + if (immediateSignal) + QVERIFY(cancelSpy.count() == 2); + else + QVERIFY(cancelSpy.count() == 1); cancelSpy.clear(); // Starting case 5: start-stop-start: expecting finished signal & no cancel diff --git a/tests/auto/qbluetoothdeviceinfo/qbluetoothdeviceinfo.pro b/tests/auto/qbluetoothdeviceinfo/qbluetoothdeviceinfo.pro index 43ca52ed..e33125c2 100644 --- a/tests/auto/qbluetoothdeviceinfo/qbluetoothdeviceinfo.pro +++ b/tests/auto/qbluetoothdeviceinfo/qbluetoothdeviceinfo.pro @@ -4,3 +4,6 @@ CONFIG += testcase QT = core concurrent bluetooth testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 +blackberry { + LIBS += -lbtapi +} diff --git a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp index adc61199..ea3c471c 100644 --- a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp +++ b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -52,6 +44,7 @@ QT_USE_NAMESPACE Q_DECLARE_METATYPE(QBluetoothDeviceInfo::ServiceClasses) Q_DECLARE_METATYPE(QBluetoothDeviceInfo::MajorDeviceClass) +Q_DECLARE_METATYPE(QBluetoothDeviceInfo::CoreConfiguration) class tst_QBluetoothDeviceInfo : public QObject { @@ -101,6 +94,7 @@ void tst_QBluetoothDeviceInfo::tst_construction_data() QTest::addColumn<QBluetoothDeviceInfo::ServiceClasses>("serviceClasses"); QTest::addColumn<QBluetoothDeviceInfo::MajorDeviceClass>("majorDeviceClass"); QTest::addColumn<quint8>("minorDeviceClass"); + QTest::addColumn<QBluetoothDeviceInfo::CoreConfiguration>("coreConfiguration"); // bits 12-8 Major // bits 7-2 Minor @@ -110,120 +104,144 @@ void tst_QBluetoothDeviceInfo::tst_construction_data() << quint32(0x000000) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::MiscellaneousDevice - << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous); + << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous) + << QBluetoothDeviceInfo::BaseRateCoreConfiguration; QTest::newRow("0x000100 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000100) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::ComputerDevice - << quint8(QBluetoothDeviceInfo::UncategorizedComputer); + << quint8(QBluetoothDeviceInfo::UncategorizedComputer) + << QBluetoothDeviceInfo::BaseRateCoreConfiguration; QTest::newRow("0x000104 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000104) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::ComputerDevice - << quint8(QBluetoothDeviceInfo::DesktopComputer); + << quint8(QBluetoothDeviceInfo::DesktopComputer) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x000118 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000118) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::ComputerDevice - << quint8(QBluetoothDeviceInfo::WearableComputer); + << quint8(QBluetoothDeviceInfo::WearableComputer) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x000200 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000200) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::PhoneDevice - << quint8(QBluetoothDeviceInfo::UncategorizedPhone); + << quint8(QBluetoothDeviceInfo::UncategorizedPhone) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x000204 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000204) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::PhoneDevice - << quint8(QBluetoothDeviceInfo::CellularPhone); + << quint8(QBluetoothDeviceInfo::CellularPhone) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x000214 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000214) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::PhoneDevice - << quint8(QBluetoothDeviceInfo::CommonIsdnAccessPhone); + << quint8(QBluetoothDeviceInfo::CommonIsdnAccessPhone) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x000300 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000300) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::LANAccessDevice - << quint8(QBluetoothDeviceInfo::NetworkFullService); + << quint8(QBluetoothDeviceInfo::NetworkFullService) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x000320 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000320) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::LANAccessDevice - << quint8(QBluetoothDeviceInfo::NetworkLoadFactorOne); + << quint8(QBluetoothDeviceInfo::NetworkLoadFactorOne) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x0003E0 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x0003E0) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::LANAccessDevice - << quint8(QBluetoothDeviceInfo::NetworkNoService); + << quint8(QBluetoothDeviceInfo::NetworkNoService) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x000400 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000400) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::AudioVideoDevice - << quint8(QBluetoothDeviceInfo::UncategorizedAudioVideoDevice); + << quint8(QBluetoothDeviceInfo::UncategorizedAudioVideoDevice) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x000448 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000448) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::AudioVideoDevice - << quint8(QBluetoothDeviceInfo::GamingDevice); + << quint8(QBluetoothDeviceInfo::GamingDevice) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x000500 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000500) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::PeripheralDevice - << quint8(QBluetoothDeviceInfo::UncategorizedPeripheral); + << quint8(QBluetoothDeviceInfo::UncategorizedPeripheral) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x0005D8 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x0005D8) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::PeripheralDevice - << quint8(QBluetoothDeviceInfo::KeyboardWithPointingDevicePeripheral | QBluetoothDeviceInfo::CardReaderPeripheral); + << quint8(QBluetoothDeviceInfo::KeyboardWithPointingDevicePeripheral | QBluetoothDeviceInfo::CardReaderPeripheral) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x000600 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000600) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::ImagingDevice - << quint8(QBluetoothDeviceInfo::UncategorizedImagingDevice); + << quint8(QBluetoothDeviceInfo::UncategorizedImagingDevice) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; QTest::newRow("0x000680 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000680) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::ImagingDevice - << quint8(QBluetoothDeviceInfo::ImagePrinter); + << quint8(QBluetoothDeviceInfo::ImagePrinter) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; QTest::newRow("0x000700 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000700) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::WearableDevice - << quint8(QBluetoothDeviceInfo::UncategorizedWearableDevice); + << quint8(QBluetoothDeviceInfo::UncategorizedWearableDevice) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; QTest::newRow("0x000714 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000714) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::WearableDevice - << quint8(QBluetoothDeviceInfo::WearableGlasses); + << quint8(QBluetoothDeviceInfo::WearableGlasses) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; QTest::newRow("0x000800 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000800) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::ToyDevice - << quint8(QBluetoothDeviceInfo::UncategorizedToy); + << quint8(QBluetoothDeviceInfo::UncategorizedToy) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; QTest::newRow("0x000814 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000814) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::ToyDevice - << quint8(QBluetoothDeviceInfo::ToyGame); + << quint8(QBluetoothDeviceInfo::ToyGame) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; QTest::newRow("0x001f00 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x001f00) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService) << QBluetoothDeviceInfo::UncategorizedDevice - << quint8(0); + << quint8(0) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; QTest::newRow("0x002000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x002000) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::PositioningService) << QBluetoothDeviceInfo::MiscellaneousDevice - << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous); + << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; QTest::newRow("0x100000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x100000) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::InformationService) << QBluetoothDeviceInfo::MiscellaneousDevice - << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous); + << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; QTest::newRow("0xFFE000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0xFFE000) << QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::AllServices) << QBluetoothDeviceInfo::MiscellaneousDevice - << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous); + << quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; } void tst_QBluetoothDeviceInfo::tst_construction() @@ -241,6 +259,7 @@ void tst_QBluetoothDeviceInfo::tst_construction() QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses); QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass); QFETCH(quint8, minorDeviceClass); + QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration); QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice); @@ -251,9 +270,12 @@ void tst_QBluetoothDeviceInfo::tst_construction() QCOMPARE(deviceInfo.serviceClasses(), serviceClasses); QCOMPARE(deviceInfo.majorDeviceClass(), majorDeviceClass); QCOMPARE(deviceInfo.minorDeviceClass(), minorDeviceClass); + QCOMPARE(deviceInfo.coreConfigurations(), QBluetoothDeviceInfo::BaseRateCoreConfiguration); - QBluetoothDeviceInfo copyInfo(deviceInfo); + deviceInfo.setCoreConfigurations(coreConfiguration); + QCOMPARE(deviceInfo.coreConfigurations(), coreConfiguration); + QBluetoothDeviceInfo copyInfo(deviceInfo); QVERIFY(copyInfo.isValid()); QCOMPARE(copyInfo.address(), address); @@ -261,6 +283,7 @@ void tst_QBluetoothDeviceInfo::tst_construction() QCOMPARE(copyInfo.serviceClasses(), serviceClasses); QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass); QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass); + QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration); } } @@ -277,8 +300,10 @@ void tst_QBluetoothDeviceInfo::tst_assignment() QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses); QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass); QFETCH(quint8, minorDeviceClass); + QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration); QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice); + deviceInfo.setCoreConfigurations(coreConfiguration); QVERIFY(deviceInfo.isValid()); @@ -292,6 +317,7 @@ void tst_QBluetoothDeviceInfo::tst_assignment() QCOMPARE(copyInfo.serviceClasses(), serviceClasses); QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass); QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass); + QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration); } { @@ -308,6 +334,7 @@ void tst_QBluetoothDeviceInfo::tst_assignment() QCOMPARE(copyInfo.serviceClasses(), serviceClasses); QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass); QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass); + QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration); } { @@ -333,6 +360,8 @@ void tst_QBluetoothDeviceInfo::tst_assignment() QCOMPARE(copyInfo2.majorDeviceClass(), majorDeviceClass); QCOMPARE(copyInfo1.minorDeviceClass(), minorDeviceClass); QCOMPARE(copyInfo2.minorDeviceClass(), minorDeviceClass); + QCOMPARE(copyInfo1.coreConfigurations(), coreConfiguration); + QCOMPARE(copyInfo2.coreConfigurations(), coreConfiguration); } { diff --git a/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp b/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp index be2cadbf..fea6bad3 100644 --- a/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp +++ b/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp index 3285592e..30e009dd 100644 --- a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp +++ b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -295,16 +287,18 @@ void tst_QBluetoothLocalDevice::tst_pairDevice_data() QTest::newRow("UnPaired Device: DUMMY->unpaired") << QBluetoothAddress("11:00:00:00:00:00") << QBluetoothLocalDevice::Unpaired << 1000 << false; + //Bluez5 may have to do a device search which can take up to 20s QTest::newRow("UnPaired Device: DUMMY->paired") << QBluetoothAddress("11:00:00:00:00:00") - << QBluetoothLocalDevice::Paired << 1000 << true; + << QBluetoothLocalDevice::Paired << 21000 << true; QTest::newRow("UnPaired Device: DUMMY") << QBluetoothAddress() << QBluetoothLocalDevice::Unpaired << 1000 << true; if (!remoteDevice.isNull()) { QTest::newRow("UnParing Test device 1") << QBluetoothAddress(remoteDevice) << QBluetoothLocalDevice::Unpaired << 1000 << false; + //Bluez5 may have to do a device search which can take up to 20s QTest::newRow("Pairing Test Device") << QBluetoothAddress(remoteDevice) - << QBluetoothLocalDevice::Paired << 10000 << false; + << QBluetoothLocalDevice::Paired << 21000 << false; QTest::newRow("Pairing upgrade for Authorization") << QBluetoothAddress(remoteDevice) << QBluetoothLocalDevice::AuthorizedPaired << 1000 << false; QTest::newRow("Unpairing Test device 2") << QBluetoothAddress(remoteDevice) diff --git a/tests/auto/qbluetoothserver/tst_qbluetoothserver.cpp b/tests/auto/qbluetoothserver/tst_qbluetoothserver.cpp index 347cddce..740ea05e 100644 --- a/tests/auto/qbluetoothserver/tst_qbluetoothserver.cpp +++ b/tests/auto/qbluetoothserver/tst_qbluetoothserver.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro b/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro index 7b8ee74a..cdf8a78b 100644 --- a/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro +++ b/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro @@ -3,5 +3,8 @@ TARGET = tst_qbluetoothservicediscoveryagent CONFIG += testcase QT = core concurrent bluetooth testlib +blackberry { + LIBS += -lbtapi +} DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp index 791bff8d..253ca50a 100644 --- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp +++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -51,11 +43,13 @@ #include <qbluetoothlocaldevice.h> #include <qbluetoothserver.h> #include <qbluetoothserviceinfo.h> +#include <qlowenergyserviceinfo.h> QT_USE_NAMESPACE Q_DECLARE_METATYPE(QBluetoothDeviceInfo) Q_DECLARE_METATYPE(QBluetoothServiceDiscoveryAgent::Error) +Q_DECLARE_METATYPE(QLowEnergyServiceInfo) // Maximum time to for bluetooth device scan const int MaxScanTime = 5 * 60 * 1000; // 5 minutes in ms @@ -71,6 +65,7 @@ public: public slots: void deviceDiscoveryDebug(const QBluetoothDeviceInfo &info); void serviceDiscoveryDebug(const QBluetoothServiceInfo &info); + void leServiceDiscoveryDebug(const QLowEnergyServiceInfo &info); void serviceError(const QBluetoothServiceDiscoveryAgent::Error err); private slots: @@ -100,6 +95,7 @@ tst_QBluetoothServiceDiscoveryAgent::tst_QBluetoothServiceDiscoveryAgent() qRegisterMetaType<QBluetoothDeviceInfo>("QBluetoothDeviceInfo"); qRegisterMetaType<QBluetoothServiceInfo>("QBluetoothServiceInfo"); + qRegisterMetaType<QLowEnergyServiceInfo>("QLowEnergyServiceInfo"); qRegisterMetaType<QList<QBluetoothUuid> >("QList<QBluetoothUuid>"); qRegisterMetaType<QBluetoothServiceDiscoveryAgent::Error>("QBluetoothServiceDiscoveryAgent::Error"); qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::Error>("QBluetoothDeviceDiscoveryAgent::Error"); @@ -180,6 +176,14 @@ void tst_QBluetoothServiceDiscoveryAgent::serviceDiscoveryDebug(const QBluetooth qDebug() << "\tRFCOMM server channel:" << info.serverChannel(); } +void tst_QBluetoothServiceDiscoveryAgent::leServiceDiscoveryDebug(const QLowEnergyServiceInfo &info) +{ + qDebug() << "Discovered LE service on" + << info.device().name() << info.device().address().toString(); + qDebug() << "\tService name:" << info.serviceName(); + qDebug() << "\tUUID:" << info.serviceUuid(); +} + static void dumpAttributeVariant(const QVariant &var, const QString indent) { if (!var.isValid()) { @@ -316,7 +320,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscoveryAdapters() QVERIFY(serviceInfo.registerService()); QVERIFY(server.isListening()); - qDebug() << "Scanning address" << addresses[0].toString(); + qDebug() << "Scanning address " << addresses[0].toString(); QBluetoothServiceDiscoveryAgent discoveryAgent(addresses[1]); bool setAddress = discoveryAgent.setRemoteAddress(addresses[0]); @@ -364,7 +368,6 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() QFETCH(QBluetoothServiceDiscoveryAgent::Error, serviceDiscoveryError); QBluetoothLocalDevice localDevice; - qDebug() << "Scanning address" << deviceInfo.address().toString(); QBluetoothServiceDiscoveryAgent discoveryAgent(localDevice.address()); bool setAddress = discoveryAgent.setRemoteAddress(deviceInfo.address()); @@ -384,14 +387,21 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() QSignalSpy finishedSpy(&discoveryAgent, SIGNAL(finished())); QSignalSpy errorSpy(&discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error))); QSignalSpy discoveredSpy(&discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo))); + QSignalSpy leDiscoveredSpy(&discoveryAgent, SIGNAL(serviceDiscovered(QLowEnergyServiceInfo))); // connect(&discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), // this, SLOT(serviceDiscoveryDebug(QBluetoothServiceInfo))); +// connect(&discoveryAgent, SIGNAL(serviceDiscovered(QLowEnergyServiceInfo)), +// this, SLOT(leServiceDiscoveryDebug(QLowEnergyServiceInfo))); connect(&discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), this, SLOT(serviceError(QBluetoothServiceDiscoveryAgent::Error))); discoveryAgent.start(); - QVERIFY(discoveryAgent.isActive()); + /* + * Either we wait for discovery agent to run its course (e.g. Bluez 4) or + * we have an immediate result (e.g. Bluez 5) + */ + QVERIFY(discoveryAgent.isActive() || !finishedSpy.isEmpty()); // Wait for up to MaxScanTime for the scan to finish int scanTime = MaxScanTime; @@ -447,6 +457,21 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery() } + while (!leDiscoveredSpy.isEmpty()) { + const QVariant v = leDiscoveredSpy.takeFirst().at(0); + if (v.userType() == qMetaTypeId<QLowEnergyServiceInfo>()) + { + const QLowEnergyServiceInfo info = + *reinterpret_cast<const QLowEnergyServiceInfo*>(v.constData()); + + QVERIFY(info.isValid()); + QVERIFY(info.device().coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration); + } else { + QFAIL("Unknown type returned by service discovery"); + } + + } + QVERIFY(discoveryAgent.discoveredServices().count() != 0); discoveryAgent.clear(); QVERIFY(discoveryAgent.discoveredServices().count() == 0); diff --git a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp index 2195bc0e..cc51b007 100644 --- a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp +++ b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp index 766bbb48..3a577db1 100644 --- a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp +++ b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -323,8 +315,8 @@ void tst_QBluetoothSocket::tst_clientCommunication_data() { QStringList data; - data << QLatin1String("Echo: Test line one.\n"); - data << QLatin1String("Echo: Test line two, with longer data.\n"); + data << QStringLiteral("Echo: Test line one.\n"); + data << QStringLiteral("Echo: Test line two, with longer data.\n"); QTest::newRow("two line test") << data; } diff --git a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp index beac5b88..89c70854 100644 --- a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp +++ b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp b/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp index 3de7aec0..a06e6ab3 100644 --- a/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp +++ b/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp b/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp index 5aae3ba9..e905eb94 100644 --- a/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp +++ b/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -72,6 +64,7 @@ private slots: void tst_conversion(); void tst_comparison_data(); void tst_comparison(); + void tst_quint128ToUuid(); }; tst_QBluetoothUuid::tst_QBluetoothUuid() @@ -252,7 +245,7 @@ void tst_QBluetoothUuid::tst_conversion_data() QTest::newRow("00112233-4455-6677-8899-AABBCCDDEEFF") << false << quint16(0) << false << quint32(0) << true << uuid128 - << QString(QLatin1String("{00112233-4455-6677-8899-AABBCCDDEEFF}")); + << QStringLiteral("{00112233-4455-6677-8899-AABBCCDDEEFF}"); } } @@ -383,6 +376,18 @@ void tst_QBluetoothUuid::tst_comparison() } } } + +void tst_QBluetoothUuid::tst_quint128ToUuid() +{ + QBluetoothUuid temp(QString("{67C8770B-44F1-410A-AB9A-F9B5446F13EE}")); + quint128 array = temp.toUInt128(); + QBluetoothUuid u(array); + QVERIFY(temp == u); + + QBENCHMARK { + QBluetoothUuid u(array); + } +} QTEST_MAIN(tst_QBluetoothUuid) #include "tst_qbluetoothuuid.moc" diff --git a/tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro b/tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro new file mode 100644 index 00000000..33302d60 --- /dev/null +++ b/tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro @@ -0,0 +1,9 @@ +SOURCES += tst_qlowenergycharacteristic.cpp +TARGET = tst_qlowenergycharacteristic +CONFIG += testcase + +QT = core bluetooth testlib +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 +blackberry { + LIBS += -lbtapi +} diff --git a/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp b/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp new file mode 100644 index 00000000..a313d1f6 --- /dev/null +++ b/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp @@ -0,0 +1,350 @@ +/*************************************************************************** +** +** Copyright (C) 2013 BlackBerry Limited all rights reserved +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtBluetooth module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QUuid> + +#include <QDebug> + +#include <QBluetoothDeviceDiscoveryAgent> +#include <QLowEnergyCharacteristic> +#include <QLowEnergyController> +#include <QBluetoothLocalDevice> + +QT_USE_NAMESPACE + +class tst_QLowEnergyCharacteristic : public QObject +{ + Q_OBJECT + +public: + tst_QLowEnergyCharacteristic(); + ~tst_QLowEnergyCharacteristic(); + +protected slots: + void deviceDiscovered(const QBluetoothDeviceInfo &info); + +private slots: + void initTestCase(); + void cleanupTestCase(); + void tst_constructionDefault(); + void tst_assignCompare(); + +private: + QSet<QString> remoteLeDevices; + QLowEnergyController *globalControl; + QLowEnergyService *globalService; +}; + +tst_QLowEnergyCharacteristic::tst_QLowEnergyCharacteristic() : + globalControl(0), globalService(0) +{ + QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); +} + +tst_QLowEnergyCharacteristic::~tst_QLowEnergyCharacteristic() +{ +} + +void tst_QLowEnergyCharacteristic::initTestCase() +{ + if (QBluetoothLocalDevice::allDevices().isEmpty()) { + qWarning("No remote device discovered."); + return; + } + + // start Bluetooth if not started + QBluetoothLocalDevice device; + device.powerOn(); + + // find an arbitrary low energy device in vincinity + // find an arbitrary service with characteristic + QBluetoothDeviceDiscoveryAgent *devAgent = new QBluetoothDeviceDiscoveryAgent(this); + connect(devAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), + this, SLOT(deviceDiscovered(QBluetoothDeviceInfo))); + + QSignalSpy errorSpy(devAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error))); + QVERIFY(errorSpy.isValid()); + QVERIFY(errorSpy.isEmpty()); + + QSignalSpy spy(devAgent, SIGNAL(finished())); + QVERIFY(spy.isValid()); + QVERIFY(spy.isEmpty()); + + devAgent->start(); + QTRY_VERIFY_WITH_TIMEOUT(spy.count() > 0, 50000); + + // find first service with descriptor + QLowEnergyController *controller = 0; + foreach (const QString &remoteDevice, remoteLeDevices.toList()) { + controller = new QLowEnergyController(QBluetoothAddress(remoteDevice), this); + qDebug() << "Connecting to" << remoteDevice; + controller->connectToDevice(); + QTRY_IMPL(controller->state() != QLowEnergyController::ConnectingState, + 10000); + if (controller->state() != QLowEnergyController::ConnectedState) { + // any error and we skip + delete controller; + qDebug() << "Skipping device"; + continue; + } + + QSignalSpy discoveryFinishedSpy(controller, SIGNAL(discoveryFinished())); + controller->discoverServices(); + QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000); + foreach (const QBluetoothUuid &leServiceUuid, controller->services()) { + QLowEnergyService *leService = controller->createServiceObject(leServiceUuid, this); + if (!leService) + continue; + + leService->discoverDetails(); + QTRY_VERIFY_WITH_TIMEOUT( + leService->state() == QLowEnergyService::ServiceDiscovered, 10000); + + QList<QLowEnergyCharacteristic> chars = leService->characteristics(); + foreach (const QLowEnergyCharacteristic &ch, chars) { + if (!ch.descriptors().isEmpty()) { + globalService = leService; + globalControl = controller; + qWarning() << "Found service with descriptor" << remoteDevice + << globalService->serviceName() << globalService->serviceUuid(); + break; + } + } + + if (globalControl) + break; + else + delete leService; + } + + if (globalControl) + break; + + delete controller; + } + + if (!globalControl) { + qWarning() << "Test limited due to missing remote QLowEnergyDescriptor." + << "Please ensure the Bluetooth Low Energy device is advertising its services."; + } +} + +void tst_QLowEnergyCharacteristic::cleanupTestCase() +{ + if (globalControl) + globalControl->disconnectFromDevice(); +} + +void tst_QLowEnergyCharacteristic::deviceDiscovered(const QBluetoothDeviceInfo &info) +{ + if (info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) + remoteLeDevices.insert(info.address().toString()); +} + +void tst_QLowEnergyCharacteristic::tst_constructionDefault() +{ + QLowEnergyCharacteristic characteristic; + QVERIFY(!characteristic.isValid()); + QCOMPARE(characteristic.value(), QByteArray()); + QVERIFY(characteristic.uuid().isNull()); + QVERIFY(characteristic.handle() == 0); + QCOMPARE(characteristic.name(), QString()); + QCOMPARE(characteristic.descriptors().count(), 0); + QCOMPARE(characteristic.descriptor(QBluetoothUuid()), + QLowEnergyDescriptor()); + QCOMPARE(characteristic.descriptor(QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)), + QLowEnergyDescriptor()); + QCOMPARE(characteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration), + QLowEnergyDescriptor()); + QCOMPARE(characteristic.properties(), QLowEnergyCharacteristic::Unknown); + + QLowEnergyCharacteristic copyConstructed(characteristic); + QVERIFY(!copyConstructed.isValid()); + QCOMPARE(copyConstructed.value(), QByteArray()); + QVERIFY(copyConstructed.uuid().isNull()); + QVERIFY(copyConstructed.handle() == 0); + QCOMPARE(copyConstructed.name(), QString()); + QCOMPARE(copyConstructed.descriptors().count(), 0); + QCOMPARE(copyConstructed.properties(), QLowEnergyCharacteristic::Unknown); + + QVERIFY(copyConstructed == characteristic); + QVERIFY(characteristic == copyConstructed); + QVERIFY(!(copyConstructed != characteristic)); + QVERIFY(!(characteristic != copyConstructed)); + + QLowEnergyCharacteristic assigned; + + QVERIFY(assigned == characteristic); + QVERIFY(characteristic == assigned); + QVERIFY(!(assigned != characteristic)); + QVERIFY(!(characteristic != assigned)); + + assigned = characteristic; + QVERIFY(!assigned.isValid()); + QCOMPARE(assigned.value(), QByteArray()); + QVERIFY(assigned.uuid().isNull()); + QVERIFY(assigned.handle() == 0); + QCOMPARE(assigned.name(), QString()); + QCOMPARE(assigned.descriptors().count(), 0); + QCOMPARE(assigned.properties(), QLowEnergyCharacteristic::Unknown); + + QVERIFY(assigned == characteristic); + QVERIFY(characteristic == assigned); + QVERIFY(!(assigned != characteristic)); + QVERIFY(!(characteristic != assigned)); +} + +void tst_QLowEnergyCharacteristic::tst_assignCompare() +{ + if (!globalService) + QSKIP("No characteristic found."); + + QLowEnergyCharacteristic target; + QVERIFY(!target.isValid()); + QCOMPARE(target.value(), QByteArray()); + QVERIFY(target.uuid().isNull()); + QVERIFY(target.handle() == 0); + QCOMPARE(target.name(), QString()); + QCOMPARE(target.descriptors().count(), 0); + QCOMPARE(target.properties(), QLowEnergyCharacteristic::Unknown); + + int indexWithDescriptor = -1; + const QList<QLowEnergyCharacteristic> chars = globalService->characteristics(); + QVERIFY(!chars.isEmpty()); + for (int i = 0; i < chars.count(); i++) { + const QLowEnergyCharacteristic specific = + globalService->characteristic(chars[i].uuid()); + QVERIFY(specific.isValid()); + QCOMPARE(specific, chars[i]); + if (chars[i].descriptors().count() > 0) { + indexWithDescriptor = i; + break; + } + } + + if (chars.isEmpty()) + QSKIP("No suitable characteristic found despite prior indication."); + + bool noDescriptors = (indexWithDescriptor == -1); + if (noDescriptors) + indexWithDescriptor = 0; // just choose one + + // test assignment operator + target = chars[indexWithDescriptor]; + QVERIFY(target.isValid()); + QVERIFY(!target.name().isEmpty()); + QVERIFY(target.handle() > 0); + QVERIFY(!target.uuid().isNull()); + QVERIFY(target.properties() != QLowEnergyCharacteristic::Unknown); + if (target.properties() & QLowEnergyCharacteristic::Read) + QVERIFY(!target.value().isEmpty()); + if (!noDescriptors) + QVERIFY(target.descriptors().count() > 0); + + QVERIFY(target == chars[indexWithDescriptor]); + QVERIFY(chars[indexWithDescriptor] == target); + QVERIFY(!(target != chars[indexWithDescriptor])); + QVERIFY(!(chars[indexWithDescriptor] != target)); + + QCOMPARE(target.isValid(), chars[indexWithDescriptor].isValid()); + QCOMPARE(target.name(), chars[indexWithDescriptor].name()); + QCOMPARE(target.handle(), chars[indexWithDescriptor].handle()); + QCOMPARE(target.uuid(), chars[indexWithDescriptor].uuid()); + QCOMPARE(target.value(), chars[indexWithDescriptor].value()); + QCOMPARE(target.properties(), chars[indexWithDescriptor].properties()); + QCOMPARE(target.descriptors().count(), + chars[indexWithDescriptor].descriptors().count()); + for (int i = 0; i < target.descriptors().count(); i++) { + const QLowEnergyDescriptor ref = chars[indexWithDescriptor].descriptors()[i]; + QCOMPARE(target.descriptors()[i].name(), ref.name()); + QCOMPARE(target.descriptors()[i].isValid(), ref.isValid()); + QCOMPARE(target.descriptors()[i].type(), ref.type()); + QCOMPARE(target.descriptors()[i].handle(), ref.handle()); + QCOMPARE(target.descriptors()[i].uuid(), ref.uuid()); + QCOMPARE(target.descriptors()[i].value(), ref.value()); + + const QLowEnergyDescriptor ref2 = chars[indexWithDescriptor].descriptor(ref.uuid()); + QCOMPARE(ref, ref2); + } + + // test copy constructor + QLowEnergyCharacteristic copyConstructed(target); + QCOMPARE(copyConstructed.isValid(), chars[indexWithDescriptor].isValid()); + QCOMPARE(copyConstructed.name(), chars[indexWithDescriptor].name()); + QCOMPARE(copyConstructed.handle(), chars[indexWithDescriptor].handle()); + QCOMPARE(copyConstructed.uuid(), chars[indexWithDescriptor].uuid()); + QCOMPARE(copyConstructed.value(), chars[indexWithDescriptor].value()); + QCOMPARE(copyConstructed.properties(), chars[indexWithDescriptor].properties()); + QCOMPARE(copyConstructed.descriptors().count(), + chars[indexWithDescriptor].descriptors().count()); + + QVERIFY(copyConstructed == target); + QVERIFY(target == copyConstructed); + QVERIFY(!(copyConstructed != target)); + QVERIFY(!(target != copyConstructed)); + + // test invalidation + QLowEnergyCharacteristic invalid; + target = invalid; + QVERIFY(!target.isValid()); + QCOMPARE(target.value(), QByteArray()); + QVERIFY(target.uuid().isNull()); + QVERIFY(target.handle() == 0); + QCOMPARE(target.name(), QString()); + QCOMPARE(target.descriptors().count(), 0); + QCOMPARE(target.properties(), QLowEnergyCharacteristic::Unknown); + + QVERIFY(invalid == target); + QVERIFY(target == invalid); + QVERIFY(!(invalid != target)); + QVERIFY(!(target != invalid)); + + QVERIFY(!(chars[indexWithDescriptor] == target)); + QVERIFY(!(target == chars[indexWithDescriptor])); + QVERIFY(chars[indexWithDescriptor] != target); + QVERIFY(target != chars[indexWithDescriptor]); + + if (chars.count() >= 2) { + // at least two characteristics + QVERIFY(!(chars[0] == chars[1])); + QVERIFY(!(chars[1] == chars[0])); + QVERIFY(chars[0] != chars[1]); + QVERIFY(chars[1] != chars[0]); + } +} + +QTEST_MAIN(tst_QLowEnergyCharacteristic) + +#include "tst_qlowenergycharacteristic.moc" diff --git a/tests/auto/qlowenergycontroller/qlowenergycontroller.pro b/tests/auto/qlowenergycontroller/qlowenergycontroller.pro new file mode 100644 index 00000000..159f27bf --- /dev/null +++ b/tests/auto/qlowenergycontroller/qlowenergycontroller.pro @@ -0,0 +1,6 @@ +QT = core bluetooth testlib +TARGET = tst_qlowenergycontroller +CONFIG += testcase + +SOURCES += tst_qlowenergycontroller.cpp + diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp new file mode 100644 index 00000000..cb5bbb07 --- /dev/null +++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp @@ -0,0 +1,1799 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtBluetooth module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QBluetoothLocalDevice> +#include <QBluetoothDeviceDiscoveryAgent> +#include <QBluetoothUuid> +#include <QLowEnergyController> +#include <QLowEnergyCharacteristic> + +#include <QDebug> + +/*! + This test requires a TI sensor tag with Firmware version: 1.5 (Oct 23 2013). + Since revision updates change user strings and even shift handles around + other versions than the above are unlikely to succeed. Please update the + sensor tag before continuing. + + The TI sensor can be updated using the related iOS app. The Android version + doesn't seem to update at this point in time. + */ + +QT_USE_NAMESPACE + +class tst_QLowEnergyController : public QObject +{ + Q_OBJECT + +public: + tst_QLowEnergyController(); + ~tst_QLowEnergyController(); + +private slots: + void initTestCase(); + void cleanupTestCase(); + void tst_connect(); + void tst_concurrentDiscovery(); + void tst_defaultBehavior(); + void tst_writeCharacteristic(); + void tst_writeDescriptor(); + +private: + void verifyServiceProperties(const QLowEnergyService *info); + + QBluetoothDeviceDiscoveryAgent *devAgent; + QBluetoothAddress remoteDevice; + QList<QBluetoothUuid> foundServices; +}; + +Q_DECLARE_METATYPE(QLowEnergyCharacteristic) +Q_DECLARE_METATYPE(QLowEnergyDescriptor) +Q_DECLARE_METATYPE(QLowEnergyService::ServiceError) + +tst_QLowEnergyController::tst_QLowEnergyController() +{ + qRegisterMetaType<QLowEnergyCharacteristic>(); + qRegisterMetaType<QLowEnergyDescriptor>(); + + //QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); + const QString remote = qgetenv("BT_TEST_DEVICE"); + if (!remote.isEmpty()) { + remoteDevice = QBluetoothAddress(remote); + qWarning() << "Using remote device " << remote << " for testing. Ensure that the device is discoverable for pairing requests"; + } else { + qWarning() << "Not using any remote device for testing. Set BT_TEST_DEVICE env to run manual tests involving a remote device"; + } +} + +tst_QLowEnergyController::~tst_QLowEnergyController() +{ + +} + +void tst_QLowEnergyController::initTestCase() +{ + if (remoteDevice.isNull() + || QBluetoothLocalDevice::allDevices().isEmpty()) { + qWarning("No remote device or local adapter found."); + return; + } + + devAgent = new QBluetoothDeviceDiscoveryAgent(this); + + QSignalSpy finishedSpy(devAgent, SIGNAL(finished())); + // there should be no changes yet + QVERIFY(finishedSpy.isValid()); + QVERIFY(finishedSpy.isEmpty()); + + bool deviceFound = false; + devAgent->start(); + QTRY_VERIFY_WITH_TIMEOUT(finishedSpy.count() > 0, 30000); + foreach (const QBluetoothDeviceInfo &info, devAgent->discoveredDevices()) { + if (info.address() == remoteDevice) { + deviceFound = true; + break; + } + } + + QVERIFY2(deviceFound, "Cannot find remote device."); + + // These are the services exported by the TI SensorTag + foundServices << QBluetoothUuid(QString("00001800-0000-1000-8000-00805f9b34fb")); + foundServices << QBluetoothUuid(QString("00001801-0000-1000-8000-00805f9b34fb")); + foundServices << QBluetoothUuid(QString("0000180a-0000-1000-8000-00805f9b34fb")); + foundServices << QBluetoothUuid(QString("0000ffe0-0000-1000-8000-00805f9b34fb")); + foundServices << QBluetoothUuid(QString("f000aa00-0451-4000-b000-000000000000")); + foundServices << QBluetoothUuid(QString("f000aa10-0451-4000-b000-000000000000")); + foundServices << QBluetoothUuid(QString("f000aa20-0451-4000-b000-000000000000")); + foundServices << QBluetoothUuid(QString("f000aa30-0451-4000-b000-000000000000")); + foundServices << QBluetoothUuid(QString("f000aa40-0451-4000-b000-000000000000")); + foundServices << QBluetoothUuid(QString("f000aa50-0451-4000-b000-000000000000")); + foundServices << QBluetoothUuid(QString("f000aa60-0451-4000-b000-000000000000")); + foundServices << QBluetoothUuid(QString("f000ccc0-0451-4000-b000-000000000000")); + foundServices << QBluetoothUuid(QString("f000ffc0-0451-4000-b000-000000000000")); +} + +void tst_QLowEnergyController::cleanupTestCase() +{ + +} + +void tst_QLowEnergyController::tst_connect() +{ + QList<QBluetoothHostInfo> localAdapters = QBluetoothLocalDevice::allDevices(); + if (localAdapters.isEmpty() || remoteDevice.isNull()) + QSKIP("No local Bluetooth or remote BTLE device found. Skipping test."); + + const QBluetoothAddress localAdapter = localAdapters.at(0).address(); + QLowEnergyController control(remoteDevice); + QSignalSpy connectedSpy(&control, SIGNAL(connected())); + QSignalSpy disconnectedSpy(&control, SIGNAL(disconnected())); + + QCOMPARE(control.localAddress(), localAdapter); + QVERIFY(!control.localAddress().isNull()); + QCOMPARE(control.remoteAddress(), remoteDevice); + QCOMPARE(control.state(), QLowEnergyController::UnconnectedState); + QCOMPARE(control.error(), QLowEnergyController::NoError); + QVERIFY(control.errorString().isEmpty()); + QCOMPARE(disconnectedSpy.count(), 0); + QCOMPARE(connectedSpy.count(), 0); + QVERIFY(control.services().isEmpty()); + + bool wasError = false; + control.connectToDevice(); + QTRY_IMPL(control.state() != QLowEnergyController::ConnectingState, + 10000); + + QCOMPARE(disconnectedSpy.count(), 0); + if (control.error() != QLowEnergyController::NoError) { + //error during connect + QCOMPARE(connectedSpy.count(), 0); + QCOMPARE(control.state(), QLowEnergyController::UnconnectedState); + wasError = true; + } else if (control.state() == QLowEnergyController::ConnectingState) { + //timeout + QCOMPARE(connectedSpy.count(), 0); + QVERIFY(control.errorString().isEmpty()); + QCOMPARE(control.error(), QLowEnergyController::NoError); + QVERIFY(control.services().isEmpty()); + QSKIP("Connection to LE device cannot be established. Skipping test."); + return; + } else { + QCOMPARE(control.state(), QLowEnergyController::ConnectedState); + QCOMPARE(connectedSpy.count(), 1); + QCOMPARE(control.error(), QLowEnergyController::NoError); + QVERIFY(control.errorString().isEmpty()); + } + + QVERIFY(control.services().isEmpty()); + + QList<QLowEnergyService *> savedReferences; + + if (!wasError) { + QSignalSpy discoveryFinishedSpy(&control, SIGNAL(discoveryFinished())); + QSignalSpy serviceFoundSpy(&control, SIGNAL(serviceDiscovered(QBluetoothUuid))); + control.discoverServices(); + QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000); + + QVERIFY(!serviceFoundSpy.isEmpty()); + QVERIFY(serviceFoundSpy.count() >= foundServices.count()); + QVERIFY(!serviceFoundSpy.isEmpty()); + QList<QBluetoothUuid> listing; + for (int i = 0; i < serviceFoundSpy.count(); i++) { + const QVariant v = serviceFoundSpy[i].at(0); + listing.append(v.value<QBluetoothUuid>()); + } + + foreach (const QBluetoothUuid &uuid, foundServices) { + QVERIFY2(listing.contains(uuid), + uuid.toString().toLatin1()); + + QLowEnergyService *service = control.createServiceObject(uuid); + QVERIFY2(service, uuid.toString().toLatin1()); + savedReferences.append(service); + QCOMPARE(service->type(), QLowEnergyService::PrimaryService); + QCOMPARE(service->state(), QLowEnergyService::DiscoveryRequired); + } + + // unrelated uuids don't return valid service object + // invalid service uuid + QVERIFY(!control.createServiceObject(QBluetoothUuid())); + // some random uuid + QVERIFY(!control.createServiceObject(QBluetoothUuid(QBluetoothUuid::DeviceName))); + + // initiate characteristic discovery + foreach (QLowEnergyService *service, savedReferences) { + qDebug() << "Discoverying" << service->serviceUuid(); + QSignalSpy stateSpy(service, + SIGNAL(stateChanged(QLowEnergyService::ServiceState))); + QSignalSpy errorSpy(service, SIGNAL(error(QLowEnergyService::ServiceError))); + service->discoverDetails(); + + QTRY_VERIFY_WITH_TIMEOUT( + service->state() == QLowEnergyService::ServiceDiscovered, 10000); + + QCOMPARE(errorSpy.count(), 0); //no error + QCOMPARE(stateSpy.count(), 2); // + + verifyServiceProperties(service); + } + + // ensure that related service objects share same state + foreach (QLowEnergyService* originalService, savedReferences) { + QLowEnergyService *newService = control.createServiceObject( + originalService->serviceUuid()); + QVERIFY(newService); + QCOMPARE(newService->state(), QLowEnergyService::ServiceDiscovered); + delete newService; + } + } + + // Finish off + control.disconnectFromDevice(); + QTRY_VERIFY_WITH_TIMEOUT( + control.state() == QLowEnergyController::UnconnectedState, + 10000); + + if (wasError) { + QCOMPARE(disconnectedSpy.count(), 0); + } else { + QCOMPARE(disconnectedSpy.count(), 1); + // after disconnect all service references must be invalid + foreach (const QLowEnergyService *entry, savedReferences) { + const QBluetoothUuid &uuid = entry->serviceUuid(); + QVERIFY2(entry->state() == QLowEnergyService::InvalidService, + uuid.toString().toLatin1()); + + //after disconnect all related characteristics and descriptors are invalid + QList<QLowEnergyCharacteristic> chars = entry->characteristics(); + for (int i = 0; i < chars.count(); i++) { + QCOMPARE(chars.at(i).isValid(), false); + QList<QLowEnergyDescriptor> descriptors = chars[i].descriptors(); + for (int j = 0; j < descriptors.count(); j++) + QCOMPARE(descriptors[j].isValid(), false); + } + } + } + + qDeleteAll(savedReferences); + savedReferences.clear(); +} + +void tst_QLowEnergyController::tst_concurrentDiscovery() +{ + QList<QBluetoothHostInfo> localAdapters = QBluetoothLocalDevice::allDevices(); + if (localAdapters.isEmpty() || remoteDevice.isNull()) + QSKIP("No local Bluetooth or remote BTLE device found. Skipping test."); + + // quick setup - more elaborate test is done by connectNew() + QLowEnergyController control(remoteDevice); + QCOMPARE(control.state(), QLowEnergyController::UnconnectedState); + QCOMPARE(control.error(), QLowEnergyController::NoError); + + control.connectToDevice(); + { + QTRY_IMPL(control.state() != QLowEnergyController::ConnectingState, + 30000); + } + + if (control.state() == QLowEnergyController::ConnectingState + || control.error() != QLowEnergyController::NoError) { + // default BTLE backend forever hangs in ConnectingState + QSKIP("Cannot connect to remote device"); + } + + QCOMPARE(control.state(), QLowEnergyController::ConnectedState); + + // 2. new controller to same device fails + { + QLowEnergyController control2(remoteDevice); + control2.connectToDevice(); + { + QTRY_IMPL(control2.state() != QLowEnergyController::ConnectingState, + 30000); + } + + QVERIFY(control2.error() != QLowEnergyController::NoError); + } + + /* We are testing that we can run service discovery on the same device + * for multiple services at the same time. + * */ + + QSignalSpy discoveryFinishedSpy(&control, SIGNAL(discoveryFinished())); + control.discoverServices(); + QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000); + + // pick MAX_SERVICES_SAME_TIME_ACCESS services + // and discover them at the same time +#define MAX_SERVICES_SAME_TIME_ACCESS 3 + QLowEnergyService *services[MAX_SERVICES_SAME_TIME_ACCESS]; + + QVERIFY(control.services().count() >= MAX_SERVICES_SAME_TIME_ACCESS); + + QList<QBluetoothUuid> uuids = control.services(); + + // initialize services + for (int i = 0; i<MAX_SERVICES_SAME_TIME_ACCESS; i++) { + services[i] = control.createServiceObject(uuids.at(i), this); + QVERIFY(services[i]); + } + + // start complete discovery + for (int i = 0; i<MAX_SERVICES_SAME_TIME_ACCESS; i++) + services[i]->discoverDetails(); + + // wait until discovery done + for (int i = 0; i<MAX_SERVICES_SAME_TIME_ACCESS; i++) { + qWarning() << "Waiting for" << i << services[i]->serviceUuid(); + QTRY_VERIFY_WITH_TIMEOUT( + services[i]->state() == QLowEnergyService::ServiceDiscovered, + 30000); + } + + // verify discovered services + for (int i = 0; i<MAX_SERVICES_SAME_TIME_ACCESS; i++) { + verifyServiceProperties(services[i]); + + QVERIFY(!services[i]->contains(QLowEnergyCharacteristic())); + QVERIFY(!services[i]->contains(QLowEnergyDescriptor())); + } + + control.disconnectFromDevice(); + QTRY_VERIFY_WITH_TIMEOUT(control.state() == QLowEnergyController::UnconnectedState, + 30000); + discoveryFinishedSpy.clear(); + + // redo the discovery with same controller + QLowEnergyService *services_second[MAX_SERVICES_SAME_TIME_ACCESS]; + control.connectToDevice(); + { + QTRY_IMPL(control.state() != QLowEnergyController::ConnectingState, + 30000); + } + + QCOMPARE(control.state(), QLowEnergyController::ConnectedState); + control.discoverServices(); + QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000); + + // get all details + for (int i = 0; i<MAX_SERVICES_SAME_TIME_ACCESS; i++) { + services_second[i] = control.createServiceObject(uuids.at(i), this); + QVERIFY(services_second[i]->parent() == this); + QVERIFY(services[i]); + QVERIFY(services_second[i]->state() == QLowEnergyService::DiscoveryRequired); + services_second[i]->discoverDetails(); + } + + // wait until discovery done + for (int i = 0; i<MAX_SERVICES_SAME_TIME_ACCESS; i++) { + qWarning() << "Waiting for" << i << services_second[i]->serviceUuid(); + QTRY_VERIFY_WITH_TIMEOUT( + services_second[i]->state() == QLowEnergyService::ServiceDiscovered, + 30000); + QCOMPARE(services_second[i]->serviceName(), services[i]->serviceName()); + QCOMPARE(services_second[i]->serviceUuid(), services[i]->serviceUuid()); + } + + // verify discovered services (1st and 2nd round) + for (int i = 0; i<MAX_SERVICES_SAME_TIME_ACCESS; i++) { + verifyServiceProperties(services_second[i]); + //after disconnect all related characteristics and descriptors are invalid + const QList<QLowEnergyCharacteristic> chars = services[i]->characteristics(); + for (int j = 0; j < chars.count(); j++) { + QCOMPARE(chars.at(j).isValid(), false); + QVERIFY(services[i]->contains(chars[j])); + QVERIFY(!services_second[i]->contains(chars[j])); + const QList<QLowEnergyDescriptor> descriptors = chars[j].descriptors(); + for (int k = 0; k < descriptors.count(); k++) { + QCOMPARE(descriptors[k].isValid(), false); + services[i]->contains(descriptors[k]); + QVERIFY(!services_second[i]->contains(chars[j])); + } + } + + QCOMPARE(services[i]->serviceUuid(), services_second[i]->serviceUuid()); + QCOMPARE(services[i]->serviceName(), services_second[i]->serviceName()); + QCOMPARE(services[i]->type(), services_second[i]->type()); + QVERIFY(services[i]->state() == QLowEnergyService::InvalidService); + QVERIFY(services_second[i]->state() == QLowEnergyService::ServiceDiscovered); + } + + // cleanup + for (int i = 0; i<MAX_SERVICES_SAME_TIME_ACCESS; i++) { + delete services[i]; + delete services_second[i]; + } + + control.disconnectFromDevice(); +} + +void tst_QLowEnergyController::verifyServiceProperties( + const QLowEnergyService *info) +{ + if (info->serviceUuid() == + QBluetoothUuid(QString("00001800-0000-1000-8000-00805f9b34fb"))) { + qDebug() << "Verifying GAP Service"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QCOMPARE(chars.count(), 5); + + // Device Name + QString temp("00002a00-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x3)); + QCOMPARE(chars[0].properties(), QLowEnergyCharacteristic::Read); + QCOMPARE(chars[0].value(), QByteArray::fromHex("544920424c452053656e736f7220546167")); + QVERIFY(chars[0].isValid()); + QCOMPARE(chars[0].descriptors().count(), 0); + QVERIFY(info->contains(chars[0])); + + // Appearance + temp = QString("00002a01-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x5)); + QCOMPARE(chars[1].properties(), QLowEnergyCharacteristic::Read); + QCOMPARE(chars[1].value(), QByteArray::fromHex("0000")); + QVERIFY(chars[1].isValid()); + QCOMPARE(chars[1].descriptors().count(), 0); + QVERIFY(info->contains(chars[1])); + + // Peripheral Privacy Flag + temp = QString("00002a02-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x7)); + QCOMPARE(chars[2].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[2].value(), QByteArray::fromHex("00")); + QVERIFY(chars[2].isValid()); + QCOMPARE(chars[2].descriptors().count(), 0); + QVERIFY(info->contains(chars[2])); + + // Reconnection Address + temp = QString("00002a03-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[3].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[3].handle(), QLowEnergyHandle(0x9)); + //Early firmware version had this characteristic as Read|Write and may fail + QCOMPARE(chars[3].properties(), QLowEnergyCharacteristic::Write); + if (chars[3].properties() & QLowEnergyCharacteristic::Read) + QCOMPARE(chars[3].value(), QByteArray::fromHex("000000000000")); + else + QCOMPARE(chars[3].value(), QByteArray()); + QVERIFY(chars[3].isValid()); + QCOMPARE(chars[3].descriptors().count(), 0); + QVERIFY(info->contains(chars[3])); + + // Peripheral Preferred Connection Parameters + temp = QString("00002a04-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[4].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[4].handle(), QLowEnergyHandle(0xb)); + QCOMPARE(chars[4].properties(), QLowEnergyCharacteristic::Read); + QCOMPARE(chars[4].value(), QByteArray::fromHex("5000a0000000e803")); + QVERIFY(chars[4].isValid()); + QCOMPARE(chars[4].descriptors().count(), 0); + QVERIFY(info->contains(chars[4])); + } else if (info->serviceUuid() == + QBluetoothUuid(QString("00001801-0000-1000-8000-00805f9b34fb"))) { + qDebug() << "Verifying GATT Service"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QCOMPARE(chars.count(), 1); + + // Service Changed + QString temp("00002a05-0000-1000-8000-00805f9b34fb"); + //this should really be readable according to GATT Service spec + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0xe)); + QCOMPARE(chars[0].properties(), QLowEnergyCharacteristic::Indicate); + QCOMPARE(chars[0].value(), QByteArray()); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + + QCOMPARE(chars[0].descriptors().count(), 1); + QCOMPARE(chars[0].descriptors().at(0).isValid(), true); + QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0xf)); + QCOMPARE(chars[0].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(chars[0].descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + QCOMPARE(chars[0].descriptors().at(0).value(), QByteArray::fromHex("0000")); + QVERIFY(info->contains(chars[0].descriptors().at(0))); + } else if (info->serviceUuid() == + QBluetoothUuid(QString("0000180a-0000-1000-8000-00805f9b34fb"))) { + qDebug() << "Verifying Device Information"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QCOMPARE(chars.count(), 9); + + // System ID + QString temp("00002a23-0000-1000-8000-00805f9b34fb"); + //this should really be readable according to GATT Service spec + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x12)); + QCOMPARE(chars[0].properties(), QLowEnergyCharacteristic::Read); + QCOMPARE(chars[0].value(), QByteArray::fromHex("6e41ab0000296abc")); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + QCOMPARE(chars[0].descriptors().count(), 0); + + // Model Number + temp = QString("00002a24-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x14)); + QCOMPARE(chars[1].properties(), QLowEnergyCharacteristic::Read); + QCOMPARE(chars[1].value(), QByteArray::fromHex("4e2e412e00")); + QVERIFY(chars[1].isValid()); + QVERIFY(info->contains(chars[1])); + QCOMPARE(chars[1].descriptors().count(), 0); + + // Serial Number + temp = QString("00002a25-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x16)); + QCOMPARE(chars[2].properties(), + (QLowEnergyCharacteristic::Read)); + QCOMPARE(chars[2].value(), QByteArray::fromHex("4e2e412e00")); + QVERIFY(chars[2].isValid()); + QVERIFY(info->contains(chars[2])); + QCOMPARE(chars[2].descriptors().count(), 0); + + // Firmware Revision + temp = QString("00002a26-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[3].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[3].handle(), QLowEnergyHandle(0x18)); + QCOMPARE(chars[3].properties(), + (QLowEnergyCharacteristic::Read)); + //FW rev. : 1.5 (Oct 23 2013) + // Other revisions will fail here + QCOMPARE(chars[3].value(), QByteArray::fromHex("312e3520284f637420323320323031332900")); + QVERIFY(chars[3].isValid()); + QVERIFY(info->contains(chars[3])); + QCOMPARE(chars[3].descriptors().count(), 0); + + // Hardware Revision + temp = QString("00002a27-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[4].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[4].handle(), QLowEnergyHandle(0x1a)); + QCOMPARE(chars[4].properties(), + (QLowEnergyCharacteristic::Read)); + QCOMPARE(chars[4].value(), QByteArray::fromHex("4e2e412e00")); + QVERIFY(chars[4].isValid()); + QVERIFY(info->contains(chars[4])); + QCOMPARE(chars[4].descriptors().count(), 0); + + // Software Revision + temp = QString("00002a28-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[5].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[5].handle(), QLowEnergyHandle(0x1c)); + QCOMPARE(chars[5].properties(), + (QLowEnergyCharacteristic::Read)); + QCOMPARE(chars[5].value(), QByteArray::fromHex("4e2e412e00")); + QVERIFY(chars[5].isValid()); + QVERIFY(info->contains(chars[5])); + QCOMPARE(chars[5].descriptors().count(), 0); + + // Manufacturer Name + temp = QString("00002a29-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[6].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[6].handle(), QLowEnergyHandle(0x1e)); + QCOMPARE(chars[6].properties(), + (QLowEnergyCharacteristic::Read)); + QCOMPARE(chars[6].value(), QByteArray::fromHex("546578617320496e737472756d656e747300")); + QVERIFY(chars[6].isValid()); + QVERIFY(info->contains(chars[6])); + QCOMPARE(chars[6].descriptors().count(), 0); + + // IEEE + temp = QString("00002a2a-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[7].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[7].handle(), QLowEnergyHandle(0x20)); + QCOMPARE(chars[7].properties(), + (QLowEnergyCharacteristic::Read)); + QCOMPARE(chars[7].value(), QByteArray::fromHex("fe006578706572696d656e74616c")); + QVERIFY(chars[7].isValid()); + QVERIFY(info->contains(chars[7])); + QCOMPARE(chars[7].descriptors().count(), 0); + + // PnP ID + temp = QString("00002a50-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[8].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[8].handle(), QLowEnergyHandle(0x22)); + QCOMPARE(chars[8].properties(), + (QLowEnergyCharacteristic::Read)); + QCOMPARE(chars[8].value(), QByteArray::fromHex("010d0000001001")); + QVERIFY(chars[8].isValid()); + QVERIFY(info->contains(chars[8])); + QCOMPARE(chars[8].descriptors().count(), 0); + } else if (info->serviceUuid() == + QBluetoothUuid(QString("f000aa00-0451-4000-b000-000000000000"))) { + qDebug() << "Verifying Temperature"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QVERIFY(chars.count() >= 2); + + // Temp Data + QString temp("f000aa01-0451-4000-b000-000000000000"); + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x25)); + QCOMPARE(chars[0].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify)); + QCOMPARE(chars[0].value(), QByteArray::fromHex("00000000")); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + + QCOMPARE(chars[0].descriptors().count(), 2); + //descriptor checks + QCOMPARE(chars[0].descriptors().at(0).isValid(), true); + QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x26)); + QCOMPARE(chars[0].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(chars[0].descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + QCOMPARE(chars[0].descriptors().at(0).value(), QByteArray::fromHex("0000")); + QVERIFY(info->contains(chars[0].descriptors().at(0))); + + QCOMPARE(chars[0].descriptors().at(1).isValid(), true); + QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x27)); + QCOMPARE(chars[0].descriptors().at(1).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[0].descriptors().at(1).type(), + QBluetoothUuid::CharacteristicUserDescription); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(1).value(), + QByteArray::fromHex("54656d702e2044617461")); + QVERIFY(info->contains(chars[0].descriptors().at(1))); + + // Temp Config + temp = QString("f000aa02-0451-4000-b000-000000000000"); + QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x29)); + QCOMPARE(chars[1].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[1].value(), QByteArray::fromHex("00")); + QVERIFY(chars[1].isValid()); + QVERIFY(info->contains(chars[1])); + + QCOMPARE(chars[1].descriptors().count(), 1); + //descriptor checks + QCOMPARE(chars[1].descriptors().at(0).isValid(), true); + QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x2a)); + QCOMPARE(chars[1].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[1].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + // value different in other revisions and test may fail + QCOMPARE(chars[1].descriptors().at(0).value(), + QByteArray::fromHex("54656d702e20436f6e662e")); + QVERIFY(info->contains(chars[1].descriptors().at(0))); + + + //Temp Period (introduced by later firmware versions) + if (chars.count() > 2) { + temp = QString("f000aa03-0451-4000-b000-000000000000"); + QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x2c)); + QCOMPARE(chars[2].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[2].value(), QByteArray::fromHex("64")); + QVERIFY(chars[2].isValid()); + QVERIFY(info->contains(chars[2])); + + QCOMPARE(chars[2].descriptors().count(), 1); + //descriptor checks + QCOMPARE(chars[2].descriptors().at(0).isValid(), true); + QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x2d)); + QCOMPARE(chars[2].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[2].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[2].descriptors().at(0).value(), + QByteArray::fromHex("54656d702e20506572696f64")); + QVERIFY(info->contains(chars[2].descriptors().at(0))); + } + } else if (info->serviceUuid() == + QBluetoothUuid(QString("0000ffe0-0000-1000-8000-00805f9b34fb"))) { + qDebug() << "Verifying Simple Keys"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QCOMPARE(chars.count(), 1); + + // Temp Data + QString temp("0000ffe1-0000-1000-8000-00805f9b34fb"); + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x6b)); + QCOMPARE(chars[0].properties(), + (QLowEnergyCharacteristic::Notify)); + QCOMPARE(chars[0].value(), QByteArray()); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + + QCOMPARE(chars[0].descriptors().count(), 2); + //descriptor checks + QCOMPARE(chars[0].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x6c)); + QCOMPARE(chars[0].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(chars[0].descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + QCOMPARE(chars[0].descriptors().at(0).value(), QByteArray::fromHex("0000")); + QVERIFY(info->contains(chars[0].descriptors().at(0))); + + QCOMPARE(chars[0].descriptors().at(1).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x6d)); + QCOMPARE(chars[0].descriptors().at(1).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[0].descriptors().at(1).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[0].descriptors().at(1).value(), + QByteArray::fromHex("4b6579205072657373205374617465")); + QVERIFY(info->contains(chars[0].descriptors().at(1))); + + } else if (info->serviceUuid() == + QBluetoothUuid(QString("f000aa10-0451-4000-b000-000000000000"))) { + qDebug() << "Verifying Accelerometer"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QCOMPARE(chars.count(), 3); + + // Accel Data + QString temp("f000aa11-0451-4000-b000-000000000000"); + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x30)); + QCOMPARE(chars[0].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify)); + QCOMPARE(chars[0].value(), QByteArray::fromHex("000000")); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + + QCOMPARE(chars[0].descriptors().count(), 2); + + QCOMPARE(chars[0].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x31)); + QCOMPARE(chars[0].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(chars[0].descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + QCOMPARE(chars[0].descriptors().at(0).value(), QByteArray::fromHex("0000")); + QVERIFY(info->contains(chars[0].descriptors().at(0))); + + QCOMPARE(chars[0].descriptors().at(1).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x32)); + QCOMPARE(chars[0].descriptors().at(1).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[0].descriptors().at(1).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[0].descriptors().at(1).value(), + QByteArray::fromHex("416363656c2e2044617461")); + QVERIFY(info->contains(chars[0].descriptors().at(1))); + + // Accel Config + temp = QString("f000aa12-0451-4000-b000-000000000000"); + QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x34)); + QCOMPARE(chars[1].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[1].value(), QByteArray::fromHex("00")); + QVERIFY(chars[1].isValid()); + QVERIFY(info->contains(chars[1])); + QCOMPARE(chars[1].descriptors().count(), 1); + + QCOMPARE(chars[1].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x35)); + QCOMPARE(chars[1].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[1].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[1].descriptors().at(0).value(), + QByteArray::fromHex("416363656c2e20436f6e662e")); + QVERIFY(info->contains(chars[1].descriptors().at(0))); + + // Accel Period + temp = QString("f000aa13-0451-4000-b000-000000000000"); + QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x37)); + QCOMPARE(chars[2].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[2].value(), QByteArray::fromHex("64")); // don't change it or set it to 0x64 + QVERIFY(chars[2].isValid()); + QVERIFY(info->contains(chars[2])); + + QCOMPARE(chars[2].descriptors().count(), 1); + //descriptor checks + QCOMPARE(chars[2].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x38)); + QCOMPARE(chars[2].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[2].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + // value different in other revisions and test may fail + QCOMPARE(chars[2].descriptors().at(0).value(), + QByteArray::fromHex("416363656c2e20506572696f64")); + QVERIFY(info->contains(chars[2].descriptors().at(0))); + } else if (info->serviceUuid() == + QBluetoothUuid(QString("f000aa20-0451-4000-b000-000000000000"))) { + qDebug() << "Verifying Humidity"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QVERIFY(chars.count() >= 2); //new firmware has more chars + + // Humidity Data + QString temp("f000aa21-0451-4000-b000-000000000000"); + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x3b)); + QCOMPARE(chars[0].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify)); + QCOMPARE(chars[0].value(), QByteArray::fromHex("00000000")); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + + QCOMPARE(chars[0].descriptors().count(), 2); + //descriptor checks + QCOMPARE(chars[0].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x3c)); + QCOMPARE(chars[0].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(chars[0].descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + QCOMPARE(chars[0].descriptors().at(0).value(), QByteArray::fromHex("0000")); + QVERIFY(info->contains(chars[0].descriptors().at(0))); + + QCOMPARE(chars[0].descriptors().at(1).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x3d)); + QCOMPARE(chars[0].descriptors().at(1).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[0].descriptors().at(1).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[0].descriptors().at(1).value(), + QByteArray::fromHex("48756d69642e2044617461")); + QVERIFY(info->contains(chars[0].descriptors().at(1))); + + // Humidity Config + temp = QString("f000aa22-0451-4000-b000-000000000000"); + QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x3f)); + QCOMPARE(chars[1].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[1].value(), QByteArray::fromHex("00")); + QVERIFY(chars[1].isValid()); + QVERIFY(info->contains(chars[1])); + + QCOMPARE(chars[1].descriptors().count(), 1); + //descriptor checks + QCOMPARE(chars[1].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x40)); + QCOMPARE(chars[1].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[1].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[1].descriptors().at(0).value(), + QByteArray::fromHex("48756d69642e20436f6e662e")); + QVERIFY(info->contains(chars[1].descriptors().at(0))); + + if (chars.count() >= 3) { + // New firmware new characteristic + // Humidity Period + temp = QString("f000aa23-0451-4000-b000-000000000000"); + QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x42)); + QCOMPARE(chars[2].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[2].value(), QByteArray::fromHex("64")); + QVERIFY(chars[2].isValid()); + QVERIFY(info->contains(chars[2])); + + QCOMPARE(chars[2].descriptors().count(), 1); + //descriptor checks + QCOMPARE(chars[2].descriptors().at(0).isValid(), true); + QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x43)); + QCOMPARE(chars[2].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[2].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[2].descriptors().at(0).value(), + QByteArray::fromHex("48756d69642e20506572696f64")); + QVERIFY(info->contains(chars[2].descriptors().at(0))); + } + } else if (info->serviceUuid() == + QBluetoothUuid(QString("f000aa30-0451-4000-b000-000000000000"))) { + qDebug() << "Verifying Magnetometer"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QCOMPARE(chars.count(), 3); + + // Magnetometer Data + QString temp("f000aa31-0451-4000-b000-000000000000"); + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x46)); + QCOMPARE(chars[0].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify)); + QCOMPARE(chars[0].value(), QByteArray::fromHex("000000000000")); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + + QCOMPARE(chars[0].descriptors().count(), 2); + + QCOMPARE(chars[0].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x47)); + QCOMPARE(chars[0].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(chars[0].descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + QCOMPARE(chars[0].descriptors().at(0).value(), QByteArray::fromHex("0000")); + QVERIFY(info->contains(chars[0].descriptors().at(0))); + + QCOMPARE(chars[0].descriptors().at(1).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x48)); + QCOMPARE(chars[0].descriptors().at(1).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[0].descriptors().at(1).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[0].descriptors().at(1).value(), + QByteArray::fromHex("4d61676e2e2044617461")); + QVERIFY(info->contains(chars[0].descriptors().at(1))); + + // Magnetometer Config + temp = QString("f000aa32-0451-4000-b000-000000000000"); + QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x4a)); + QCOMPARE(chars[1].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[1].value(), QByteArray::fromHex("00")); + QVERIFY(chars[1].isValid()); + QVERIFY(info->contains(chars[1])); + + QCOMPARE(chars[1].descriptors().count(), 1); + QCOMPARE(chars[1].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x4b)); + QCOMPARE(chars[1].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[1].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + // value different in other revisions and test may fail + QCOMPARE(chars[1].descriptors().at(0).value(), + QByteArray::fromHex("4d61676e2e20436f6e662e")); + QVERIFY(info->contains(chars[1].descriptors().at(0))); + + // Magnetometer Period + temp = QString("f000aa33-0451-4000-b000-000000000000"); + QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x4d)); + QCOMPARE(chars[2].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[2].value(), QByteArray::fromHex("c8")); // don't change it or set it to 0xc8 + QVERIFY(chars[2].isValid()); + QVERIFY(info->contains(chars[2])); + + QCOMPARE(chars[2].descriptors().count(), 1); + QCOMPARE(chars[2].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x4e)); + QCOMPARE(chars[2].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[2].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + // value different in other revisions and test may fail + QCOMPARE(chars[2].descriptors().at(0).value(), + QByteArray::fromHex("4d61676e2e20506572696f64")); + QVERIFY(info->contains(chars[2].descriptors().at(0))); + } else if (info->serviceUuid() == + QBluetoothUuid(QString("f000aa40-0451-4000-b000-000000000000"))) { + qDebug() << "Verifying Pressure"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QVERIFY(chars.count() >= 3); + + // Pressure Data + QString temp("f000aa41-0451-4000-b000-000000000000"); + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x51)); + QCOMPARE(chars[0].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify)); + QCOMPARE(chars[0].value(), QByteArray::fromHex("00000000")); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + + QCOMPARE(chars[0].descriptors().count(), 2); + //descriptor checks + QCOMPARE(chars[0].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x52)); + QCOMPARE(chars[0].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(chars[0].descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + QCOMPARE(chars[0].descriptors().at(0).value(), QByteArray::fromHex("0000")); + QVERIFY(info->contains(chars[0].descriptors().at(0))); + + QCOMPARE(chars[0].descriptors().at(1).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x53)); + QCOMPARE(chars[0].descriptors().at(1).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[0].descriptors().at(1).type(), + QBluetoothUuid::CharacteristicUserDescription); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(1).value(), + QByteArray::fromHex("4261726f6d2e2044617461")); + QVERIFY(info->contains(chars[0].descriptors().at(1))); + + // Pressure Config + temp = QString("f000aa42-0451-4000-b000-000000000000"); + QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x55)); + QCOMPARE(chars[1].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[1].value(), QByteArray::fromHex("00")); + QVERIFY(chars[1].isValid()); + QVERIFY(info->contains(chars[1])); + + QCOMPARE(chars[1].descriptors().count(), 1); + QCOMPARE(chars[1].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x56)); + QCOMPARE(chars[1].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[1].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[1].descriptors().at(0).value(), + QByteArray::fromHex("4261726f6d2e20436f6e662e")); + QVERIFY(info->contains(chars[1].descriptors().at(0))); + + //calibration and period characteristic are swapped, ensure we don't depend on their order + QLowEnergyCharacteristic calibration, period; + foreach (const QLowEnergyCharacteristic &ch, chars) { + //find calibration characteristic + if (ch.uuid() == QBluetoothUuid(QString("f000aa43-0451-4000-b000-000000000000"))) + calibration = ch; + else if (ch.uuid() == QBluetoothUuid(QString("f000aa44-0451-4000-b000-000000000000"))) + period = ch; + } + + if (calibration.isValid()) { + // Pressure Calibration + temp = QString("f000aa43-0451-4000-b000-000000000000"); + QCOMPARE(calibration.uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(calibration.handle(), QLowEnergyHandle(0x5b)); + QCOMPARE(calibration.properties(), + (QLowEnergyCharacteristic::Read)); + QCOMPARE(calibration.value(), QByteArray::fromHex("00000000000000000000000000000000")); // don't change it + QVERIFY(calibration.isValid()); + QVERIFY(info->contains(calibration)); + + QCOMPARE(calibration.descriptors().count(), 2); + //descriptor checks + QCOMPARE(calibration.descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(calibration.descriptors().at(0).handle(), QLowEnergyHandle(0x5c)); + QCOMPARE(calibration.descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(calibration.descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + QCOMPARE(calibration.descriptors().at(0).value(), QByteArray::fromHex("0000")); + QVERIFY(info->contains(calibration.descriptors().at(0))); + + QCOMPARE(calibration.descriptors().at(1).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(calibration.descriptors().at(1).handle(), QLowEnergyHandle(0x5d)); + QCOMPARE(calibration.descriptors().at(1).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(calibration.descriptors().at(1).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(calibration.descriptors().at(1).value(), + QByteArray::fromHex("4261726f6d2e2043616c6962722e")); + QVERIFY(info->contains(calibration.descriptors().at(1))); + } + + if (period.isValid()) { + // Period Calibration + temp = QString("f000aa44-0451-4000-b000-000000000000"); + QCOMPARE(period.uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(period.handle(), QLowEnergyHandle(0x58)); + QCOMPARE(period.properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(period.value(), QByteArray::fromHex("64")); + QVERIFY(period.isValid()); + QVERIFY(info->contains(period)); + + QCOMPARE(period.descriptors().count(), 1); + //descriptor checks + QCOMPARE(period.descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(period.descriptors().at(0).handle(), QLowEnergyHandle(0x59)); + QCOMPARE(period.descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(period.descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(period.descriptors().at(0).value(), + QByteArray::fromHex("4261726f6d2e20506572696f64")); + QVERIFY(info->contains(period.descriptors().at(0))); + } + } else if (info->serviceUuid() == + QBluetoothUuid(QString("f000aa50-0451-4000-b000-000000000000"))) { + qDebug() << "Verifying Gyroscope"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QVERIFY(chars.count() >= 2); + + // Gyroscope Data + QString temp("f000aa51-0451-4000-b000-000000000000"); + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x60)); + QCOMPARE(chars[0].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify)); + QCOMPARE(chars[0].value(), QByteArray::fromHex("000000000000")); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + + QCOMPARE(chars[0].descriptors().count(), 2); + //descriptor checks + QCOMPARE(chars[0].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x61)); + QCOMPARE(chars[0].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(chars[0].descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + QCOMPARE(chars[0].descriptors().at(0).value(), QByteArray::fromHex("0000")); + QVERIFY(info->contains(chars[0].descriptors().at(0))); + + QCOMPARE(chars[0].descriptors().at(1).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x62)); + QCOMPARE(chars[0].descriptors().at(1).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[0].descriptors().at(1).type(), + QBluetoothUuid::CharacteristicUserDescription); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(1).value(), + QByteArray::fromHex("4779726f2044617461")); + QVERIFY(info->contains(chars[0].descriptors().at(1))); + + // Gyroscope Config + temp = QString("f000aa52-0451-4000-b000-000000000000"); + QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x64)); + QCOMPARE(chars[1].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[1].value(), QByteArray::fromHex("00")); + QVERIFY(chars[1].isValid()); + QVERIFY(info->contains(chars[1])); + + QCOMPARE(chars[1].descriptors().count(), 1); + //descriptor checks + QCOMPARE(chars[1].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x65)); + QCOMPARE(chars[1].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[1].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[1].descriptors().at(0).value(), + QByteArray::fromHex("4779726f20436f6e662e")); + QVERIFY(info->contains(chars[1].descriptors().at(0))); + + // Gyroscope Period + temp = QString("f000aa53-0451-4000-b000-000000000000"); + QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x67)); + QCOMPARE(chars[2].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[2].value(), QByteArray::fromHex("64")); + QVERIFY(chars[2].isValid()); + QVERIFY(info->contains(chars[2])); + + QCOMPARE(chars[2].descriptors().count(), 1); + //descriptor checks + QCOMPARE(chars[2].descriptors().at(0).isValid(), true); + QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x68)); + QCOMPARE(chars[2].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[2].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[2].descriptors().at(0).value(), + QByteArray::fromHex("4779726f20506572696f64")); + QVERIFY(info->contains(chars[2].descriptors().at(0))); + } else if (info->serviceUuid() == + QBluetoothUuid(QString("f000aa60-0451-4000-b000-000000000000"))) { + qDebug() << "Verifying Test Service"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QCOMPARE(chars.count(), 2); + + // Test Data + QString temp("f000aa61-0451-4000-b000-000000000000"); + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x70)); + QCOMPARE(chars[0].properties(), + (QLowEnergyCharacteristic::Read)); + QCOMPARE(chars[0].value(), QByteArray::fromHex("3f00")); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + + QCOMPARE(chars[0].descriptors().count(), 1); + QCOMPARE(chars[0].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x71)); + QCOMPARE(chars[0].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[0].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[0].descriptors().at(0).value(), + QByteArray::fromHex("546573742044617461")); + QVERIFY(info->contains(chars[0].descriptors().at(0))); + + // Test Config + temp = QString("f000aa62-0451-4000-b000-000000000000"); + QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x73)); + QCOMPARE(chars[1].properties(), + (QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write)); + QCOMPARE(chars[1].value(), QByteArray::fromHex("00")); + QVERIFY(chars[1].isValid()); + QVERIFY(info->contains(chars[1])); + + QCOMPARE(chars[1].descriptors().count(), 1); + //descriptor checks + QCOMPARE(chars[1].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x74)); + QCOMPARE(chars[1].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[1].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[1].descriptors().at(0).value(), + QByteArray::fromHex("5465737420436f6e666967")); + QVERIFY(info->contains(chars[1].descriptors().at(0))); + } else if (info->serviceUuid() == + QBluetoothUuid(QString("f000ccc0-0451-4000-b000-000000000000"))) { + qDebug() << "Connection Control Service"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QCOMPARE(chars.count(), 3); + + //first characteristic + QString temp("f000ccc1-0451-4000-b000-000000000000"); + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x77)); + QCOMPARE(chars[0].properties(), + (QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Read)); + QCOMPARE(chars[0].value(), QByteArray::fromHex("000000000000")); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + + QCOMPARE(chars[0].descriptors().count(), 2); + //descriptor checks + QCOMPARE(chars[0].descriptors().at(0).isValid(), true); + QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x78)); + QCOMPARE(chars[0].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(chars[0].descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(0).value(), QByteArray::fromHex("0100")); + QVERIFY(info->contains(chars[0].descriptors().at(0))); + + QCOMPARE(chars[0].descriptors().at(1).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x79)); + QCOMPARE(chars[0].descriptors().at(1).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[0].descriptors().at(1).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[0].descriptors().at(1).value(), + QByteArray::fromHex("436f6e6e2e20506172616d73")); + QVERIFY(info->contains(chars[0].descriptors().at(1))); + + //second characteristic + temp = QString("f000ccc2-0451-4000-b000-000000000000"); + QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x7b)); + QCOMPARE(chars[1].properties(), QLowEnergyCharacteristic::Write); + QCOMPARE(chars[1].value(), QByteArray()); + QVERIFY(chars[1].isValid()); + QVERIFY(info->contains(chars[1])); + + QCOMPARE(chars[1].descriptors().count(), 1); + QCOMPARE(chars[1].descriptors().at(0).isValid(), true); + QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x7c)); + QCOMPARE(chars[1].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[1].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[1].descriptors().at(0).value(), + QByteArray::fromHex("436f6e6e2e20506172616d7320526571")); + QVERIFY(info->contains(chars[1].descriptors().at(0))); + + //third characteristic + temp = QString("f000ccc3-0451-4000-b000-000000000000"); + QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp)); + QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x7e)); + QCOMPARE(chars[2].properties(), QLowEnergyCharacteristic::Write); + QCOMPARE(chars[2].value(), QByteArray()); + QVERIFY(chars[2].isValid()); + QVERIFY(info->contains(chars[2])); + + QCOMPARE(chars[2].descriptors().count(), 1); + QCOMPARE(chars[2].descriptors().at(0).isValid(), true); + QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x7f)); + QCOMPARE(chars[2].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[2].descriptors().at(0).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[2].descriptors().at(0).value(), + QByteArray::fromHex("446973636f6e6e65637420526571")); + QVERIFY(info->contains(chars[2].descriptors().at(0))); + } else if (info->serviceUuid() == + QBluetoothUuid(QString("f000ffc0-0451-4000-b000-000000000000"))) { + qDebug() << "Verifying OID Service"; + QList<QLowEnergyCharacteristic> chars = info->characteristics(); + QCOMPARE(chars.count(), 2); + + // first characteristic + QString temp("f000ffc1-0451-4000-b000-000000000000"); + QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x82)); + QCOMPARE(chars[0].properties(), + (QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristic::WriteNoResponse)); + QCOMPARE(chars[0].value(), QByteArray()); + QVERIFY(chars[0].isValid()); + QVERIFY(info->contains(chars[0])); + + QCOMPARE(chars[0].descriptors().count(), 2); + //descriptor checks + QCOMPARE(chars[0].descriptors().at(0).isValid(), true); + QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x83)); + QCOMPARE(chars[0].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(chars[0].descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(0).value(), QByteArray::fromHex("0100")); + QVERIFY(info->contains(chars[0].descriptors().at(0))); + + QCOMPARE(chars[0].descriptors().at(1).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x84)); + QCOMPARE(chars[0].descriptors().at(1).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[0].descriptors().at(1).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[0].descriptors().at(1).value(), + QByteArray::fromHex("496d67204964656e74696679")); + QVERIFY(info->contains(chars[0].descriptors().at(1))); + + // second characteristic + temp = QString("f000ffc2-0451-4000-b000-000000000000"); + QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp)); + // value different in other revisions and test may fail + QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x86)); + QCOMPARE(chars[1].properties(), + (QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristic::WriteNoResponse)); + QCOMPARE(chars[1].value(), QByteArray()); + QVERIFY(chars[1].isValid()); + QVERIFY(info->contains(chars[1])); + + QCOMPARE(chars[1].descriptors().count(), 2); + //descriptor checks + QCOMPARE(chars[1].descriptors().at(0).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x87)); + QCOMPARE(chars[1].descriptors().at(0).uuid(), + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + QCOMPARE(chars[1].descriptors().at(0).type(), + QBluetoothUuid::ClientCharacteristicConfiguration); + // value different in other revisions and test may fail + QCOMPARE(chars[1].descriptors().at(0).value(), QByteArray::fromHex("0100")); + QVERIFY(info->contains(chars[1].descriptors().at(0))); + + QCOMPARE(chars[1].descriptors().at(1).isValid(), true); + // value different in other revisions and test may fail + QCOMPARE(chars[1].descriptors().at(1).handle(), QLowEnergyHandle(0x88)); + QCOMPARE(chars[1].descriptors().at(1).uuid(), + QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription)); + QCOMPARE(chars[1].descriptors().at(1).type(), + QBluetoothUuid::CharacteristicUserDescription); + QCOMPARE(chars[1].descriptors().at(1).value(), + QByteArray::fromHex("496d6720426c6f636b")); + QVERIFY(info->contains(chars[1].descriptors().at(1))); + } else { + QFAIL(QString("Service not found" + info->serviceUuid().toString()).toUtf8().constData()); + } +} + +void tst_QLowEnergyController::tst_defaultBehavior() +{ + QList<QBluetoothAddress> foundAddresses; + foreach (const QBluetoothHostInfo &info, QBluetoothLocalDevice::allDevices()) + foundAddresses.append(info.address()); + const QBluetoothAddress randomAddress("11:22:33:44:55:66"); + + // Test automatic detection of local adapter + QLowEnergyController controlDefaultAdapter(randomAddress); + QCOMPARE(controlDefaultAdapter.remoteAddress(), randomAddress); + QCOMPARE(controlDefaultAdapter.state(), QLowEnergyController::UnconnectedState); + if (foundAddresses.isEmpty()) { + QVERIFY(controlDefaultAdapter.localAddress().isNull()); + } else { + QCOMPARE(controlDefaultAdapter.error(), QLowEnergyController::NoError); + QVERIFY(controlDefaultAdapter.errorString().isEmpty()); + QVERIFY(foundAddresses.contains(controlDefaultAdapter.localAddress())); + + // unrelated uuids don't return valid service object + // invalid service uuid + QVERIFY(!controlDefaultAdapter.createServiceObject( + QBluetoothUuid())); + // some random uuid + QVERIFY(!controlDefaultAdapter.createServiceObject( + QBluetoothUuid(QBluetoothUuid::DeviceName))); + } + + QCOMPARE(controlDefaultAdapter.services().count(), 0); + + // Test explicit local adapter + if (!foundAddresses.isEmpty()) { + QLowEnergyController controlExplicitAdapter(randomAddress, + foundAddresses[0]); + QCOMPARE(controlExplicitAdapter.remoteAddress(), randomAddress); + QCOMPARE(controlExplicitAdapter.localAddress(), foundAddresses[0]); + QCOMPARE(controlExplicitAdapter.state(), + QLowEnergyController::UnconnectedState); + QCOMPARE(controlExplicitAdapter.services().count(), 0); + + // unrelated uuids don't return valid service object + // invalid service uuid + QVERIFY(!controlExplicitAdapter.createServiceObject( + QBluetoothUuid())); + // some random uuid + QVERIFY(!controlExplicitAdapter.createServiceObject( + QBluetoothUuid(QBluetoothUuid::DeviceName))); + } +} + +void tst_QLowEnergyController::tst_writeCharacteristic() +{ + QList<QBluetoothHostInfo> localAdapters = QBluetoothLocalDevice::allDevices(); + if (localAdapters.isEmpty() || remoteDevice.isNull()) + QSKIP("No local Bluetooth or remote BTLE device found. Skipping test."); + + // quick setup - more elaborate test is done by connect() + QLowEnergyController control(remoteDevice); + QCOMPARE(control.error(), QLowEnergyController::NoError); + + control.connectToDevice(); + { + QTRY_IMPL(control.state() != QLowEnergyController::ConnectingState, + 30000); + } + + if (control.state() == QLowEnergyController::ConnectingState + || control.error() != QLowEnergyController::NoError) { + // default BTLE backend forever hangs in ConnectingState + QSKIP("Cannot connect to remote device"); + } + + QCOMPARE(control.state(), QLowEnergyController::ConnectedState); + QSignalSpy discoveryFinishedSpy(&control, SIGNAL(discoveryFinished())); + control.discoverServices(); + QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000); + + const QBluetoothUuid testService(QString("f000aa60-0451-4000-b000-000000000000")); + QList<QBluetoothUuid> uuids = control.services(); + QVERIFY(uuids.contains(testService)); + + QLowEnergyService *service = control.createServiceObject(testService, this); + QVERIFY(service); + service->discoverDetails(); + QTRY_VERIFY_WITH_TIMEOUT( + service->state() == QLowEnergyService::ServiceDiscovered, 30000); + + //test service described by http://processors.wiki.ti.com/index.php/SensorTag_User_Guide + const QList<QLowEnergyCharacteristic> chars = service->characteristics(); + + QLowEnergyCharacteristic dataChar; + QLowEnergyCharacteristic configChar; + for (int i = 0; i < chars.count(); i++) { + if (chars[i].uuid() == QBluetoothUuid(QString("f000aa61-0451-4000-b000-000000000000"))) + dataChar = chars[i]; + else if (chars[i].uuid() == QBluetoothUuid(QString("f000aa62-0451-4000-b000-000000000000"))) + configChar = chars[i]; + } + + QVERIFY(dataChar.isValid()); + QVERIFY(!(dataChar.properties() & ~QLowEnergyCharacteristic::Read)); // only a read char + QVERIFY(service->contains(dataChar)); + QVERIFY(configChar.isValid()); + QVERIFY(configChar.properties() & QLowEnergyCharacteristic::Write); + QVERIFY(service->contains(configChar)); + + QCOMPARE(dataChar.value(), QByteArray::fromHex("3f00")); + QVERIFY(configChar.value() == QByteArray::fromHex("00") + || configChar.value() == QByteArray::fromHex("81")); + + QSignalSpy writeSpy(service, + SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray))); + + // ******************************************* + // test writing of characteristic + // enable Blinking LED if not already enabled + if (configChar.value() != QByteArray("81")) { + service->writeCharacteristic(configChar, QByteArray::fromHex("81")); //0x81 blink LED D1 + QTRY_VERIFY_WITH_TIMEOUT(!writeSpy.isEmpty(), 10000); + QCOMPARE(configChar.value(), QByteArray::fromHex("81")); + QList<QVariant> firstSignalData = writeSpy.first(); + QLowEnergyCharacteristic signalChar = firstSignalData[0].value<QLowEnergyCharacteristic>(); + QByteArray signalValue = firstSignalData[1].toByteArray(); + + QCOMPARE(signalValue, QByteArray::fromHex("81")); + QVERIFY(signalChar == configChar); + + writeSpy.clear(); + } + + service->writeCharacteristic(configChar, QByteArray::fromHex("00")); //0x81 blink LED D1 + QTRY_VERIFY_WITH_TIMEOUT(!writeSpy.isEmpty(), 10000); + QCOMPARE(configChar.value(), QByteArray::fromHex("00")); + QList<QVariant> firstSignalData = writeSpy.first(); + QLowEnergyCharacteristic signalChar = firstSignalData[0].value<QLowEnergyCharacteristic>(); + QByteArray signalValue = firstSignalData[1].toByteArray(); + + QCOMPARE(signalValue, QByteArray::fromHex("00")); + QVERIFY(signalChar == configChar); + + // ******************************************* + // write wrong value -> error response required + QSignalSpy errorSpy(service, SIGNAL(error(QLowEnergyService::ServiceError))); + writeSpy.clear(); + QCOMPARE(errorSpy.count(), 0); + QCOMPARE(writeSpy.count(), 0); + + // write 2 byte value to 1 byte characteristic + service->writeCharacteristic(configChar, QByteArray::fromHex("1111")); + QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000); + QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(), + QLowEnergyService::CharacteristicWriteError); + QCOMPARE(service->error(), QLowEnergyService::CharacteristicWriteError); + QCOMPARE(writeSpy.count(), 0); + QCOMPARE(configChar.value(), QByteArray::fromHex("00")); + + // ******************************************* + // write to read-only characteristic -> error + errorSpy.clear(); + QCOMPARE(errorSpy.count(), 0); + service->writeCharacteristic(dataChar, QByteArray::fromHex("ffff")); + + QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000); + QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(), + QLowEnergyService::OperationError); + QCOMPARE(service->error(), QLowEnergyService::OperationError); + QCOMPARE(writeSpy.count(), 0); + QCOMPARE(dataChar.value(), QByteArray::fromHex("3f00")); + + + control.disconnectFromDevice(); + + // ******************************************* + // write value while disconnected -> error + errorSpy.clear(); + QCOMPARE(errorSpy.count(), 0); + service->writeCharacteristic(configChar, QByteArray::fromHex("ffff")); + QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 2000); + QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(), + QLowEnergyService::OperationError); + QCOMPARE(service->error(), QLowEnergyService::OperationError); + QCOMPARE(writeSpy.count(), 0); + QCOMPARE(configChar.value(), QByteArray::fromHex("00")); + + // invalid characteristics still belong to their respective service + QVERIFY(service->contains(configChar)); + QVERIFY(service->contains(dataChar)); + + QVERIFY(!service->contains(QLowEnergyCharacteristic())); + + delete service; +} + +void tst_QLowEnergyController::tst_writeDescriptor() +{ + QList<QBluetoothHostInfo> localAdapters = QBluetoothLocalDevice::allDevices(); + if (localAdapters.isEmpty() || remoteDevice.isNull()) + QSKIP("No local Bluetooth or remote BTLE device found. Skipping test."); + + // quick setup - more elaborate test is done by connect() + QLowEnergyController control(remoteDevice); + control.connectToDevice(); + { + QTRY_IMPL(control.state() != QLowEnergyController::ConnectingState, + 30000); + } + + if (control.state() == QLowEnergyController::ConnectingState + || control.error() != QLowEnergyController::NoError) { + // default BTLE backend forever hangs in ConnectingState + QSKIP("Cannot connect to remote device"); + } + + QCOMPARE(control.state(), QLowEnergyController::ConnectedState); + QSignalSpy discoveryFinishedSpy(&control, SIGNAL(discoveryFinished())); + control.discoverServices(); + QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000); + + const QBluetoothUuid testService(QString("f000aa00-0451-4000-b000-000000000000")); + QList<QBluetoothUuid> uuids = control.services(); + QVERIFY(uuids.contains(testService)); + + QLowEnergyService *service = control.createServiceObject(testService, this); + QVERIFY(service); + service->discoverDetails(); + QTRY_VERIFY_WITH_TIMEOUT( + service->state() == QLowEnergyService::ServiceDiscovered, 30000); + + // Temperature service described by + // http://processors.wiki.ti.com/index.php/SensorTag_User_Guide + + // 1. Find temperature data characteristic + const QLowEnergyCharacteristic tempData = service->characteristic( + QBluetoothUuid(QStringLiteral("f000aa01-0451-4000-b000-000000000000"))); + const QLowEnergyCharacteristic tempConfig = service->characteristic( + QBluetoothUuid(QStringLiteral("f000aa02-0451-4000-b000-000000000000"))); + + if (!tempData.isValid()) { + delete service; + control.disconnectFromDevice(); + QSKIP("Cannot find temperature data characteristic of TI Sensor"); + } + + // 2. Find temperature data notification descriptor + const QLowEnergyDescriptor notification = tempData.descriptor( + QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration)); + + if (!notification.isValid()) { + delete service; + control.disconnectFromDevice(); + QSKIP("Cannot find temperature data notification of TI Sensor"); + } + + QCOMPARE(notification.value(), QByteArray::fromHex("0000")); + service->contains(notification); + service->contains(tempData); + if (tempConfig.isValid()) { + service->contains(tempConfig); + QCOMPARE(tempConfig.value(), QByteArray::fromHex("00")); + } + + // 3. Test writing to descriptor -> activate notifications + QSignalSpy descChangedSpy(service, + SIGNAL(descriptorChanged(QLowEnergyDescriptor,QByteArray))); + QSignalSpy charChangedSpy(service, + SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray))); + service->writeDescriptor(notification, QByteArray::fromHex("0100")); + // verify + QTRY_VERIFY_WITH_TIMEOUT(!descChangedSpy.isEmpty(), 3000); + QCOMPARE(notification.value(), QByteArray::fromHex("0100")); + QList<QVariant> firstSignalData = descChangedSpy.first(); + QLowEnergyDescriptor signalDesc = firstSignalData[0].value<QLowEnergyDescriptor>(); + QByteArray signalValue = firstSignalData[1].toByteArray(); + QCOMPARE(signalValue, QByteArray::fromHex("0100")); + QVERIFY(notification == signalDesc); + descChangedSpy.clear(); + + // 4. Test reception of notifications + // activate the temperature sensor if available + if (tempConfig.isValid()) { + service->writeCharacteristic(tempConfig, QByteArray::fromHex("01")); + + // first signal is confirmation of tempConfig write + // subsequent signals are temp data updates + QTRY_VERIFY_WITH_TIMEOUT(charChangedSpy.count() >= 5, 10000); + QList<QVariant> entry; + for (int i = 0; i < charChangedSpy.count(); i++) { + entry = charChangedSpy[i]; + const QLowEnergyCharacteristic ch = entry[0].value<QLowEnergyCharacteristic>(); + const QByteArray val = entry[1].toByteArray(); + + if (i == 0) { + QCOMPARE(tempConfig, ch); + } else { + qDebug() << "Temp update: " << hex << ch.handle() << val.toHex(); + QCOMPARE(tempData, ch); + } + } + + service->writeCharacteristic(tempConfig, QByteArray::fromHex("00")); + } + + // 5. Test writing to descriptor -> deactivate notifications + service->writeDescriptor(notification, QByteArray::fromHex("0000")); + // verify + QTRY_VERIFY_WITH_TIMEOUT(!descChangedSpy.isEmpty(), 3000); + QCOMPARE(notification.value(), QByteArray::fromHex("0000")); + firstSignalData = descChangedSpy.first(); + signalDesc = firstSignalData[0].value<QLowEnergyDescriptor>(); + signalValue = firstSignalData[1].toByteArray(); + QCOMPARE(signalValue, QByteArray::fromHex("0000")); + QVERIFY(notification == signalDesc); + descChangedSpy.clear(); + + // ******************************************* + // write wrong value -> error response required + QSignalSpy errorSpy(service, SIGNAL(error(QLowEnergyService::ServiceError))); + descChangedSpy.clear(); + QCOMPARE(errorSpy.count(), 0); + QCOMPARE(descChangedSpy.count(), 0); + + // write 4 byte value to 2 byte characteristic + service->writeDescriptor(notification, QByteArray::fromHex("11112222")); + QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 30000); + QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(), + QLowEnergyService::DescriptorWriteError); + QCOMPARE(service->error(), QLowEnergyService::DescriptorWriteError); + QCOMPARE(descChangedSpy.count(), 0); + QCOMPARE(notification.value(), QByteArray::fromHex("0000")); + + control.disconnectFromDevice(); + + // ******************************************* + // write value while disconnected -> error + errorSpy.clear(); + service->writeDescriptor(notification, QByteArray::fromHex("0100")); + QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 2000); + QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(), + QLowEnergyService::OperationError); + QCOMPARE(service->error(), QLowEnergyService::OperationError); + QCOMPARE(descChangedSpy.count(), 0); + QCOMPARE(notification.value(), QByteArray::fromHex("0000")); + + delete service; +} + +QTEST_MAIN(tst_QLowEnergyController) + +#include "tst_qlowenergycontroller.moc" diff --git a/tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro b/tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro new file mode 100644 index 00000000..60b5a740 --- /dev/null +++ b/tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro @@ -0,0 +1,8 @@ +SOURCES += tst_qlowenergydescriptor.cpp +TARGET = tst_qlowenergydescriptor +CONFIG += testcase + +QT = core bluetooth testlib +blackberry { + LIBS += -lbtapi +} diff --git a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp new file mode 100644 index 00000000..3b22d2e3 --- /dev/null +++ b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp @@ -0,0 +1,318 @@ +/*************************************************************************** +** +** Copyright (C) 2013 BlackBerry Limited all rights reserved +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtBluetooth module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QUuid> + +#include <QDebug> + +#include <QBluetoothDeviceDiscoveryAgent> +#include <QLowEnergyDescriptor> +#include <QLowEnergyController> +#include <QBluetoothLocalDevice> + +QT_USE_NAMESPACE + +class tst_QLowEnergyDescriptor : public QObject +{ + Q_OBJECT + +public: + tst_QLowEnergyDescriptor(); + ~tst_QLowEnergyDescriptor(); + +protected slots: + void deviceDiscovered(const QBluetoothDeviceInfo &info); + +private slots: + void initTestCase(); + void cleanupTestCase(); + void tst_constructionDefault(); + void tst_assignCompare(); + +private: + QSet<QString> remoteLeDevices; + QLowEnergyController *globalControl; + QLowEnergyService *globalService; +}; + +tst_QLowEnergyDescriptor::tst_QLowEnergyDescriptor() : + globalControl(0), globalService(0) +{ + QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); +} + +tst_QLowEnergyDescriptor::~tst_QLowEnergyDescriptor() +{ +} + +void tst_QLowEnergyDescriptor::initTestCase() +{ + if (QBluetoothLocalDevice::allDevices().isEmpty()) { + qWarning("No remote device discovered."); + + return; + } + + // start Bluetooth if not started + QBluetoothLocalDevice device; + device.powerOn(); + + // find an arbitrary low energy device in vincinity + // find an arbitrary service with descriptor + + QBluetoothDeviceDiscoveryAgent *devAgent = new QBluetoothDeviceDiscoveryAgent(this); + connect(devAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), + this, SLOT(deviceDiscovered(QBluetoothDeviceInfo))); + + QSignalSpy errorSpy(devAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error))); + QVERIFY(errorSpy.isValid()); + QVERIFY(errorSpy.isEmpty()); + + QSignalSpy spy(devAgent, SIGNAL(finished())); + // there should be no changes yet + QVERIFY(spy.isValid()); + QVERIFY(spy.isEmpty()); + + devAgent->start(); + QTRY_VERIFY_WITH_TIMEOUT(spy.count() > 0, 50000); + + // find first service with descriptor + QLowEnergyController *controller = 0; + foreach (const QString &remoteDevice, remoteLeDevices.toList()) { + controller = new QLowEnergyController(QBluetoothAddress(remoteDevice), this); + qDebug() << "Connecting to" << remoteDevice; + controller->connectToDevice(); + QTRY_IMPL(controller->state() != QLowEnergyController::ConnectingState, + 10000); + if (controller->state() != QLowEnergyController::ConnectedState) { + // any error and we skip + delete controller; + qDebug() << "Skipping device"; + continue; + } + + QSignalSpy discoveryFinishedSpy(controller, SIGNAL(discoveryFinished())); + controller->discoverServices(); + QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000); + foreach (const QBluetoothUuid &leServiceUuid, controller->services()) { + QLowEnergyService *leService = controller->createServiceObject(leServiceUuid, this); + if (!leService) + continue; + + leService->discoverDetails(); + QTRY_VERIFY_WITH_TIMEOUT( + leService->state() == QLowEnergyService::ServiceDiscovered, 10000); + + QList<QLowEnergyCharacteristic> chars = leService->characteristics(); + foreach (const QLowEnergyCharacteristic &ch, chars) { + if (!ch.descriptors().isEmpty()) { + globalService = leService; + globalControl = controller; + qWarning() << "Found service with descriptor" << remoteDevice + << globalService->serviceName() << globalService->serviceUuid(); + break; + } + } + + if (globalControl) + break; + else + delete leService; + } + + if (globalControl) + break; + + delete controller; + } + + if (!globalControl) { + qWarning() << "Test limited due to missing remote QLowEnergyDescriptor." + << "Please ensure the Bluetooth Low Energy device is advertising its services."; + } +} + +void tst_QLowEnergyDescriptor::cleanupTestCase() +{ + if (globalControl) + globalControl->disconnectFromDevice(); +} + +void tst_QLowEnergyDescriptor::deviceDiscovered(const QBluetoothDeviceInfo &info) +{ + if (info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) + remoteLeDevices.insert(info.address().toString()); +} + +void tst_QLowEnergyDescriptor::tst_constructionDefault() +{ + QLowEnergyDescriptor descriptor; + QVERIFY(!descriptor.isValid()); + QCOMPARE(descriptor.value(), QByteArray()); + QVERIFY(descriptor.uuid().isNull()); + QVERIFY(descriptor.handle() == 0); + QCOMPARE(descriptor.name(), QString()); + QCOMPARE(descriptor.type(), QBluetoothUuid::UnknownDescriptorType); + + QLowEnergyDescriptor copyConstructed(descriptor); + QVERIFY(!copyConstructed.isValid()); + QCOMPARE(copyConstructed.value(), QByteArray()); + QVERIFY(copyConstructed.uuid().isNull()); + QVERIFY(copyConstructed.handle() == 0); + QCOMPARE(copyConstructed.name(), QString()); + QCOMPARE(copyConstructed.type(), QBluetoothUuid::UnknownDescriptorType); + + QVERIFY(copyConstructed == descriptor); + QVERIFY(descriptor == copyConstructed); + QVERIFY(!(copyConstructed != descriptor)); + QVERIFY(!(descriptor != copyConstructed)); + + QLowEnergyDescriptor assigned; + + QVERIFY(assigned == descriptor); + QVERIFY(descriptor == assigned); + QVERIFY(!(assigned != descriptor)); + QVERIFY(!(descriptor != assigned)); + + assigned = descriptor; + QVERIFY(!assigned.isValid()); + QCOMPARE(assigned.value(), QByteArray()); + QVERIFY(assigned.uuid().isNull()); + QVERIFY(assigned.handle() == 0); + QCOMPARE(assigned.name(), QString()); + QCOMPARE(assigned.type(), QBluetoothUuid::UnknownDescriptorType); + + QVERIFY(assigned == descriptor); + QVERIFY(descriptor == assigned); + QVERIFY(!(assigned != descriptor)); + QVERIFY(!(descriptor != assigned)); +} + + +void tst_QLowEnergyDescriptor::tst_assignCompare() +{ + //find the descriptor + if (!globalService) + QSKIP("No descriptor found."); + + QLowEnergyDescriptor target; + QVERIFY(!target.isValid()); + QCOMPARE(target.type(), QBluetoothUuid::UnknownDescriptorType); + QCOMPARE(target.name(), QString()); + QCOMPARE(target.handle(), QLowEnergyHandle(0)); + QCOMPARE(target.uuid(), QBluetoothUuid()); + QCOMPARE(target.value(), QByteArray()); + + QList<QLowEnergyDescriptor> targets; + const QList<QLowEnergyCharacteristic> chars = globalService->characteristics(); + foreach (const QLowEnergyCharacteristic &ch, chars) { + if (!ch.descriptors().isEmpty()) { + targets = ch.descriptors(); + break; + } + } + + if (targets.isEmpty()) + QSKIP("No descriptor found despite prior indication."); + + // test assignment operator + target = targets.first(); + QVERIFY(target.isValid()); + QVERIFY(target.type() != QBluetoothUuid::UnknownDescriptorType); + QVERIFY(!target.name().isEmpty()); + QVERIFY(target.handle() > 0); + QVERIFY(!target.uuid().isNull()); + QVERIFY(!target.value().isEmpty()); + + QVERIFY(target == targets.first()); + QVERIFY(targets.first() == target); + QVERIFY(!(target != targets.first())); + QVERIFY(!(targets.first() != target)); + + QCOMPARE(target.isValid(), targets.first().isValid()); + QCOMPARE(target.type(), targets.first().type()); + QCOMPARE(target.name(), targets.first().name()); + QCOMPARE(target.handle(), targets.first().handle()); + QCOMPARE(target.uuid(), targets.first().uuid()); + QCOMPARE(target.value(), targets.first().value()); + + // test copy constructor + QLowEnergyDescriptor copyConstructed(target); + QCOMPARE(copyConstructed.isValid(), targets.first().isValid()); + QCOMPARE(copyConstructed.type(), targets.first().type()); + QCOMPARE(copyConstructed.name(), targets.first().name()); + QCOMPARE(copyConstructed.handle(), targets.first().handle()); + QCOMPARE(copyConstructed.uuid(), targets.first().uuid()); + QCOMPARE(copyConstructed.value(), targets.first().value()); + + QVERIFY(copyConstructed == target); + QVERIFY(target == copyConstructed); + QVERIFY(!(copyConstructed != target)); + QVERIFY(!(target != copyConstructed)); + + // test invalidation + QLowEnergyDescriptor invalid; + target = invalid; + QVERIFY(!target.isValid()); + QCOMPARE(target.value(), QByteArray()); + QVERIFY(target.uuid().isNull()); + QVERIFY(target.handle() == 0); + QCOMPARE(target.name(), QString()); + QCOMPARE(target.type(), QBluetoothUuid::UnknownDescriptorType); + + QVERIFY(invalid == target); + QVERIFY(target == invalid); + QVERIFY(!(invalid != target)); + QVERIFY(!(target != invalid)); + + QVERIFY(!(targets.first() == target)); + QVERIFY(!(target == targets.first())); + QVERIFY(targets.first() != target); + QVERIFY(target != targets.first()); + + if (targets.count() >= 2) { + QLowEnergyDescriptor second = targets[1]; + // at least two descriptors + QVERIFY(!(targets.first() == second)); + QVERIFY(!(second == targets.first())); + QVERIFY(targets.first() != second); + QVERIFY(second != targets.first()); + } +} + +QTEST_MAIN(tst_QLowEnergyDescriptor) + +#include "tst_qlowenergydescriptor.moc" + diff --git a/tests/auto/qlowenergyserviceinfo/qlowenergyserviceinfo.pro b/tests/auto/qlowenergyserviceinfo/qlowenergyserviceinfo.pro new file mode 100644 index 00000000..1dd24a97 --- /dev/null +++ b/tests/auto/qlowenergyserviceinfo/qlowenergyserviceinfo.pro @@ -0,0 +1,9 @@ +SOURCES += tst_qlowenergyserviceinfo.cpp +TARGET = tst_qlowenergyserviceinfo +CONFIG += testcase + +QT = core bluetooth testlib +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 +blackberry { + LIBS += -lbtapi +} diff --git a/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp b/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp new file mode 100644 index 00000000..23ea6dd2 --- /dev/null +++ b/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp @@ -0,0 +1,243 @@ +/*************************************************************************** +** +** 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. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QUuid> + +#include <QDebug> + +#include <qbluetoothdeviceinfo.h> +#include <qlowenergyserviceinfo.h> +#include <qbluetoothaddress.h> +#include <qbluetoothlocaldevice.h> +#include <qbluetoothuuid.h> + +QT_USE_NAMESPACE + +Q_DECLARE_METATYPE(QUuid) +Q_DECLARE_METATYPE(QBluetoothDeviceInfo::CoreConfiguration) +Q_DECLARE_METATYPE(QLowEnergyServiceInfo) +Q_DECLARE_METATYPE(QBluetoothUuid::ServiceClassUuid) + +class tst_QLowEnergyServiceInfo : public QObject +{ + Q_OBJECT + +public: + tst_QLowEnergyServiceInfo(); + ~tst_QLowEnergyServiceInfo(); + +private slots: + void initTestCase(); + void tst_construction(); + void tst_assignment_data(); + void tst_assignment(); +}; + +tst_QLowEnergyServiceInfo::tst_QLowEnergyServiceInfo() +{ +} + +tst_QLowEnergyServiceInfo::~tst_QLowEnergyServiceInfo() +{ +} + +void tst_QLowEnergyServiceInfo::initTestCase() +{ + // start Bluetooth if not started + QBluetoothLocalDevice *device = new QBluetoothLocalDevice(); + device->powerOn(); + delete device; +} + +void tst_QLowEnergyServiceInfo::tst_construction() +{ + const QBluetoothUuid serviceUuid(QBluetoothUuid::HeartRate); + const QBluetoothUuid alternateServiceUuid(QBluetoothUuid::BatteryService); + const QBluetoothDeviceInfo deviceInfo(QBluetoothAddress("001122334455"), "Test Device", 0); + const QBluetoothDeviceInfo alternatedeviceInfo(QBluetoothAddress("554433221100"), "Test Device2", 0); + + { + QLowEnergyServiceInfo serviceInfo; + + QVERIFY(!serviceInfo.isValid()); + QCOMPARE(serviceInfo.serviceName(), QStringLiteral("Unknown Service")); + QCOMPARE(serviceInfo.serviceUuid().toString(), QBluetoothUuid().toString()); + QCOMPARE(serviceInfo.device(), QBluetoothDeviceInfo()); + } + + { + QLowEnergyServiceInfo serviceInfo(serviceUuid); + serviceInfo.setDevice(deviceInfo); + + QVERIFY(serviceInfo.isValid()); + + QCOMPARE(serviceInfo.serviceUuid().toString(), serviceUuid.toString()); + QCOMPARE(serviceInfo.device().address(), deviceInfo.address()); + + QLowEnergyServiceInfo copyInfo(serviceInfo); + + QVERIFY(copyInfo.isValid()); + + QCOMPARE(copyInfo.serviceUuid().toString(), serviceUuid.toString()); + QCOMPARE(copyInfo.device().address(), deviceInfo.address()); + + + copyInfo = QLowEnergyServiceInfo(alternateServiceUuid); + copyInfo.setDevice(alternatedeviceInfo); + QCOMPARE(copyInfo.serviceUuid(), alternateServiceUuid); + + QCOMPARE(copyInfo.device().address(), alternatedeviceInfo.address()); + + } +} + +void tst_QLowEnergyServiceInfo::tst_assignment_data() +{ + QTest::addColumn<QBluetoothAddress>("address"); + QTest::addColumn<QString>("name"); + QTest::addColumn<quint32>("classOfDevice"); + QTest::addColumn<QBluetoothUuid>("serviceClassUuid"); + QTest::addColumn<QBluetoothDeviceInfo::CoreConfiguration>("coreConfiguration"); + + // bits 12-8 Major + // bits 7-2 Minor + // bits 1-0 0 + + QTest::newRow("0x000000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" + << quint32(0x000000) + << QBluetoothUuid(QBluetoothUuid::GenericAccess) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; + QTest::newRow("0x000100 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" + << quint32(0x000100) + << QBluetoothUuid(QBluetoothUuid::GenericAttribute) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; + QTest::newRow("0x000104 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" + << quint32(0x000104) + << QBluetoothUuid(QBluetoothUuid::HeartRate) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; + QTest::newRow("0x000118 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" + << quint32(0x000118) + << QBluetoothUuid(QBluetoothUuid::CyclingSpeedAndCadence) + << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration; + QTest::newRow("0x000200 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" + << quint32(0x000200) + << QBluetoothUuid(QBluetoothUuid::CyclingPower) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; + QTest::newRow("0x000204 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" + << quint32(0x000204) + << QBluetoothUuid(QBluetoothUuid::ScanParameters) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; + QTest::newRow("0x000214 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" + << quint32(0x000214) + << QBluetoothUuid(QBluetoothUuid::DeviceInformation) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; + QTest::newRow("0x000300 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" + << quint32(0x000300) + << QBluetoothUuid(QBluetoothUuid::CurrentTimeService) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; + QTest::newRow("0x000320 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" + << quint32(0x000320) + << QBluetoothUuid(QBluetoothUuid::LocationAndNavigation) + << QBluetoothDeviceInfo::LowEnergyCoreConfiguration; +} + +void tst_QLowEnergyServiceInfo::tst_assignment() +{ + QFETCH(QBluetoothAddress, address); + QFETCH(QString, name); + QFETCH(quint32, classOfDevice); + QFETCH(QBluetoothUuid, serviceClassUuid); + QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration); + + QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice); + deviceInfo.setCoreConfigurations(coreConfiguration); + QCOMPARE(deviceInfo.coreConfigurations(), coreConfiguration); + + QLowEnergyServiceInfo serviceInfo(serviceClassUuid); + serviceInfo.setDevice(deviceInfo); + QCOMPARE(serviceInfo.device(), deviceInfo); + + QVERIFY(serviceInfo.isValid()); + + { + QLowEnergyServiceInfo copyInfo = serviceInfo; + + QVERIFY(copyInfo.isValid()); + + QCOMPARE(copyInfo.device().address(), address); + QCOMPARE(copyInfo.serviceUuid(), serviceClassUuid); + QCOMPARE(copyInfo.device().coreConfigurations(), coreConfiguration); + QCOMPARE(copyInfo.device(), deviceInfo); + } + + { + QLowEnergyServiceInfo copyInfo; + + QVERIFY(!copyInfo.isValid()); + + copyInfo = serviceInfo; + + QVERIFY(copyInfo.isValid()); + + QCOMPARE(copyInfo.device().address(), address); + QCOMPARE(copyInfo.serviceUuid(), serviceClassUuid); + QCOMPARE(copyInfo.device().coreConfigurations(), coreConfiguration); + } + + { + QLowEnergyServiceInfo copyInfo1; + QLowEnergyServiceInfo copyInfo2; + + QVERIFY(!copyInfo1.isValid()); + QVERIFY(!copyInfo2.isValid()); + + copyInfo1 = copyInfo2 = serviceInfo; + + QVERIFY(copyInfo1.isValid()); + QVERIFY(copyInfo2.isValid()); + + QCOMPARE(copyInfo1.device().address(), address); + QCOMPARE(copyInfo2.device().address(), address); + QCOMPARE(copyInfo1.serviceUuid(), serviceClassUuid); + QCOMPARE(copyInfo2.serviceUuid(), serviceClassUuid); + QCOMPARE(copyInfo1.device().coreConfigurations(), coreConfiguration); + QCOMPARE(copyInfo2.device().coreConfigurations(), coreConfiguration); + QCOMPARE(copyInfo1.device(), deviceInfo); + QCOMPARE(copyInfo2.device(), deviceInfo); + } +} + +QTEST_MAIN(tst_QLowEnergyServiceInfo) + +#include "tst_qlowenergyserviceinfo.moc" diff --git a/tests/auto/qndefmessage/tst_qndefmessage.cpp b/tests/auto/qndefmessage/tst_qndefmessage.cpp index 5813d0cd..c697a5e5 100644 --- a/tests/auto/qndefmessage/tst_qndefmessage.cpp +++ b/tests/auto/qndefmessage/tst_qndefmessage.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -174,7 +166,10 @@ void tst_QNdefMessage::tst_parse_data() QList<QNdefRecord> recordList; recordList.append(record); QTest::newRow("chunked") << data << QNdefMessage(recordList) << QVariantList(); - QCOMPARE(qHash(record), 1887494681LL); + + const QByteArray recordContent = record.type() + record.id() + + record.payload(); + QCOMPARE(recordContent, QByteArray::fromHex(QByteArray("7479706569647061796c6f6164"))); } // NFC-RTD Text @@ -202,9 +197,13 @@ void tst_QNdefMessage::tst_parse_data() QList<QNdefRecord> recordList; recordList.append(record); QTest::newRow("nfc-rtd text") << data << QNdefMessage(recordList) - << (QVariantList() << QLatin1String("Test String") - << QLatin1String("en")); - QCOMPARE(qHash(record), 3247259560LL); + << (QVariantList() << QStringLiteral("Test String") + << QStringLiteral("en")); + + const QByteArray recordContent = record.type() + record.id() + + record.payload(); + QCOMPARE(recordContent, + QByteArray::fromHex(QByteArray("5402656e5465737420537472696e67"))); } // NFC-RTD Text @@ -235,8 +234,12 @@ void tst_QNdefMessage::tst_parse_data() << data << QNdefMessage(recordList) << (QVariantList() << QString::fromUtf8("\343\203\206\343\202\271\343\203\210\346\226" "\207\345\255\227\345\210\227") - << QLatin1String("ja")); - QCOMPARE(qHash(record), 3407917933LL); + << QStringLiteral("ja")); + + const QByteArray recordContent = record.type() + record.id() + + record.payload(); + QCOMPARE(recordContent, + QByteArray::fromHex(QByteArray("54026a61e38386e382b9e38388e69687e5ad97e58897"))); } // NFC-RTD URI @@ -244,7 +247,7 @@ void tst_QNdefMessage::tst_parse_data() QByteArray type("U"); QByteArray payload; payload.append(char(0x00)); - payload.append("http://qt.nokia.com/"); + payload.append("http://qt-project.org/"); QByteArray data; data.append(char(0xc1)); @@ -259,13 +262,17 @@ void tst_QNdefMessage::tst_parse_data() QNdefRecord record; record.setTypeNameFormat(QNdefRecord::NfcRtd); record.setType("U"); - record.setPayload(QByteArray("\000http://qt.nokia.com/", 21)); + record.setPayload(QByteArray("\000http://qt-project.org/", 23)); QList<QNdefRecord> recordList; recordList.append(record); - QTest::newRow("nfc-rtd uri http://qt.nokia.com/") + QTest::newRow("nfc-rtd uri http://qt-project.org/") << data << QNdefMessage(recordList) - << (QVariantList() << QUrl(QLatin1String("http://qt.nokia.com/"))); - QCOMPARE(qHash(record), 4030951038LL); + << (QVariantList() << QUrl(QStringLiteral("http://qt-project.org/"))); + + const QByteArray recordContent = record.type() + record.id() + + record.payload(); + QCOMPARE(recordContent, + QByteArray::fromHex(QByteArray("5500687474703a2f2f71742d70726f6a6563742e6f72672f"))); } // NFC-RTD URI @@ -273,7 +280,7 @@ void tst_QNdefMessage::tst_parse_data() QByteArray type("U"); QByteArray payload; payload.append(char(0x03)); - payload.append("qt.nokia.com/"); + payload.append("qt-project.org/"); QByteArray data; data.append(char(0xc1)); @@ -288,13 +295,17 @@ void tst_QNdefMessage::tst_parse_data() QNdefRecord record; record.setTypeNameFormat(QNdefRecord::NfcRtd); record.setType("U"); - record.setPayload(QByteArray("\003qt.nokia.com/", 14)); + record.setPayload(QByteArray("\003qt-project.org/", 16)); QList<QNdefRecord> recordList; recordList.append(record); - QTest::newRow("nfc-rtd uri abbrev http://qt.nokia.com/") + QTest::newRow("nfc-rtd uri abbrev http://qt-project.org/") << data << QNdefMessage(recordList) - << (QVariantList() << QUrl(QLatin1String("http://qt.nokia.com/"))); - QCOMPARE(qHash(record), 132405495LL); + << (QVariantList() << QUrl(QStringLiteral("http://qt-project.org/"))); + + const QByteArray recordContent = record.type() + record.id() + + record.payload(); + QCOMPARE(recordContent, + QByteArray::fromHex(QByteArray("550371742d70726f6a6563742e6f72672f"))); } // NFC-RTD URI @@ -322,8 +333,12 @@ void tst_QNdefMessage::tst_parse_data() recordList.append(record); QTest::newRow("nfc-rtd uri tel:+1234567890") << data << QNdefMessage(recordList) - << (QVariantList() << QUrl(QLatin1String("tel:+1234567890"))); - QCOMPARE(qHash(record), 3757269174LL); + << (QVariantList() << QUrl(QStringLiteral("tel:+1234567890"))); + + const QByteArray recordContent = record.type() + record.id() + + record.payload(); + QCOMPARE(recordContent, + QByteArray::fromHex(QByteArray("55052b31323334353637383930"))); } // Truncated message @@ -332,7 +347,7 @@ void tst_QNdefMessage::tst_parse_data() QByteArray id("Test ID"); QByteArray payload; payload.append(char(0x00)); - payload.append("http://qt.nokia.com/"); + payload.append("http://qt-project.org/"); QByteArray data; data.append(char(0xc9)); // MB=1, ME=1, IL=1 diff --git a/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp b/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp index c16fb211..f5b51710 100644 --- a/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp +++ b/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp @@ -5,36 +5,28 @@ ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/qndefrecord/tst_qndefrecord.cpp b/tests/auto/qndefrecord/tst_qndefrecord.cpp index 000ff017..5e776423 100644 --- a/tests/auto/qndefrecord/tst_qndefrecord.cpp +++ b/tests/auto/qndefrecord/tst_qndefrecord.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -164,7 +156,7 @@ void tst_QNdefRecord::tst_record() { QNdefRecord record; record.setTypeNameFormat(QNdefRecord::ExternalRtd); - record.setType("qt.nokia.com:test-rtd"); + record.setType("qt-project.org:test-rtd"); record.setId("test id"); record.setPayload("test payload"); @@ -196,13 +188,13 @@ void tst_QNdefRecord::tst_record() { QNdefRecord record; record.setTypeNameFormat(QNdefRecord::ExternalRtd); - record.setType("qt.nokia.com:test-rtd"); + record.setType("qt-project.org:test-rtd"); record.setId("test id"); record.setPayload("test payload"); QNdefRecord other; other.setTypeNameFormat(QNdefRecord::ExternalRtd); - other.setType("qt.nokia.com:test-other-rtd"); + other.setType("qt-project.org:test-other-rtd"); other.setId("test other id"); other.setPayload("test other payload"); @@ -301,14 +293,14 @@ void tst_QNdefRecord::tst_uriRecord_data() QTest::addColumn<QByteArray>("payload"); - QTest::newRow("http") << QString::fromLatin1("http://qt.nokia.com/") - << QByteArray::fromHex("0371742E6E6F6B69612E636F6D2F"); + QTest::newRow("http") << QString::fromLatin1("http://qt-project.org/") + << QByteArray::fromHex("0371742d70726f6a6563742e6f72672f"); QTest::newRow("tel") << QString::fromLatin1("tel:+1234567890") << QByteArray::fromHex("052B31323334353637383930"); QTest::newRow("mailto") << QString::fromLatin1("mailto:test@example.com") << QByteArray::fromHex("0674657374406578616D706C652E636F6D"); - QTest::newRow("urn") << QString::fromLatin1("urn:nfc:ext:qt.nokia.com:test") - << QByteArray::fromHex("136E66633A6578743A71742E6E6F6B69612E636F6D3A74657374"); + QTest::newRow("urn") << QString::fromLatin1("urn:nfc:ext:qt-project.org:test") + << QByteArray::fromHex("136E66633A6578743A71742D70726F6A6563742E6F72673A74657374"); } void tst_QNdefRecord::tst_uriRecord() diff --git a/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp b/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp index f431ce6f..694b6b1b 100644 --- a/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp +++ b/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp b/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp index bbe72e5a..0d733e1d 100644 --- a/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp +++ b/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -421,7 +413,7 @@ void tst_QNearFieldTagType1::ndefMessages() QList<QNdefMessage> messages; QNdefNfcTextRecord textRecord; - textRecord.setText(QLatin1String("tst_QNearFieldTagType1::ndefMessages")); + textRecord.setText(QStringLiteral("tst_QNearFieldTagType1::ndefMessages")); QNdefMessage message; message.append(textRecord); @@ -429,7 +421,7 @@ void tst_QNearFieldTagType1::ndefMessages() if (target->memorySize() > 120) { QNdefRecord record; record.setTypeNameFormat(QNdefRecord::ExternalRtd); - record.setType("com.nokia.qt:ndefMessagesTest"); + record.setType("org.qt-project:ndefMessagesTest"); record.setPayload(QByteArray(120, quint8(0x55))); message.append(record); } diff --git a/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp b/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp index 6fac6571..39a2c68b 100644 --- a/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp +++ b/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -313,7 +305,7 @@ void tst_QNearFieldTagType2::ndefMessages() QList<QNdefMessage> messages; QNdefNfcTextRecord textRecord; - textRecord.setText(QLatin1String("tst_QNearFieldTagType2::ndefMessages")); + textRecord.setText(QStringLiteral("tst_QNearFieldTagType2::ndefMessages")); QNdefMessage message; message.append(textRecord); @@ -321,7 +313,7 @@ void tst_QNearFieldTagType2::ndefMessages() if (target->memorySize() > 120) { QNdefRecord record; record.setTypeNameFormat(QNdefRecord::ExternalRtd); - record.setType("com.nokia.qt:ndefMessagesTest"); + record.setType("org.qt-project:ndefMessagesTest"); record.setPayload(QByteArray(120, quint8(0x55))); message.append(record); } diff --git a/tests/bttestui/Button.qml b/tests/bttestui/Button.qml index 25cffb43..03903fd0 100644 --- a/tests/bttestui/Button.qml +++ b/tests/bttestui/Button.qml @@ -5,36 +5,28 @@ ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/bttestui/btlocaldevice.cpp b/tests/bttestui/btlocaldevice.cpp index a14709ee..247c00e6 100644 --- a/tests/bttestui/btlocaldevice.cpp +++ b/tests/bttestui/btlocaldevice.cpp @@ -5,36 +5,28 @@ ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -83,6 +75,8 @@ BtLocalDevice::BtLocalDevice(QObject *parent) : serviceAgent = new QBluetoothServiceDiscoveryAgent(this); connect(serviceAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), this, SLOT(serviceDiscovered(QBluetoothServiceInfo))); + connect(serviceAgent, SIGNAL(serviceDiscovered(QLowEnergyServiceInfo)), + this, SLOT(leServiceDiscovered(QLowEnergyServiceInfo))); connect(serviceAgent, SIGNAL(finished()), this, SLOT(serviceDiscoveryFinished())); connect(serviceAgent, SIGNAL(canceled()), @@ -149,10 +143,20 @@ void BtLocalDevice::requestPairingUpdate(bool isPairing) if (baddr.isNull()) return; - if (isPairing) - localDevice->requestPairing(baddr, QBluetoothLocalDevice::Paired); - else + + + if (isPairing) { + //toggle between authorized and non-authorized pairing to achieve better + //level of testing + static short pairing = 0; + if ((pairing%2) == 1) + localDevice->requestPairing(baddr, QBluetoothLocalDevice::Paired); + else + localDevice->requestPairing(baddr, QBluetoothLocalDevice::AuthorizedPaired); + pairing++; + } else { localDevice->requestPairing(baddr, QBluetoothLocalDevice::Unpaired); + } for (int i = 0; i < foundTestServers.count(); i++) { if (isPairing) @@ -296,11 +300,11 @@ void BtLocalDevice::stopServiceDiscovery() void BtLocalDevice::serviceDiscovered(const QBluetoothServiceInfo &info) { - QString classIds; - foreach (const QBluetoothUuid uuid, info.serviceClassUuids()) - classIds += uuid.toString() + QLatin1Char(' '); + QStringList classIds; + foreach (const QBluetoothUuid &uuid, info.serviceClassUuids()) + classIds.append(uuid.toString()); qDebug() << "$$ Found new service" << info.device().address().toString() - << info.serviceUuid() << info.serviceName() << classIds; + << info.serviceUuid() << info.serviceName() << info.serviceDescription() << classIds; if (info.serviceUuid() == QBluetoothUuid(QString(TEST_SERVICE_UUID)) || info.serviceClassUuids().contains(QBluetoothUuid(QString(TEST_SERVICE_UUID)))) @@ -321,6 +325,12 @@ void BtLocalDevice::serviceDiscovered(const QBluetoothServiceInfo &info) } } +void BtLocalDevice::leServiceDiscovered(const QLowEnergyServiceInfo &info) +{ + qDebug() << "$$ Found new BTLE service" << info.device().address().toString() + << info.serviceUuid() << info.serviceName(); +} + void BtLocalDevice::serviceDiscoveryFinished() { qDebug() << "###### Service Discovery Finished"; @@ -348,7 +358,7 @@ void BtLocalDevice::dumpServiceDiscovery() qDebug() << "Discovered Devices:" << list.count(); foreach (const QBluetoothDeviceInfo &info, list) - qDebug() << info.name() << info.address().toString(); + qDebug() << info.name() << info.address().toString() << info.rssi(); } if (serviceAgent) { qDebug() << "Service Discovery active:" << serviceAgent->isActive(); @@ -490,7 +500,10 @@ void BtLocalDevice::readData() if (socket) { while (socket->canReadLine()) { QByteArray line = socket->readLine().trimmed(); - qDebug() << ">>>>" << QString::fromUtf8(line.constData(), line.length()); + qDebug() << ">> peer(" << socket->peerName() << socket->peerAddress() + << socket->peerPort() << ") local(" + << socket->localName() << socket->localAddress() << socket->localPort() + << ")>>" << QString::fromUtf8(line.constData(), line.length()); } } } @@ -633,7 +646,7 @@ void BtLocalDevice::clientSocketReadyRead() while (socket->canReadLine()) { const QByteArray line = socket->readLine().trimmed(); QString lineString = QString::fromUtf8(line.constData(), line.length()); - qDebug() << ">>(" << socket->peerName() << ")>>" + qDebug() << ">>(" << server->serverAddress() << server->serverPort() <<")>>" << lineString; //when using the tst_QBluetoothSocket we echo received text back diff --git a/tests/bttestui/btlocaldevice.h b/tests/bttestui/btlocaldevice.h index 01d9b0df..53e4797b 100644 --- a/tests/bttestui/btlocaldevice.h +++ b/tests/bttestui/btlocaldevice.h @@ -5,36 +5,28 @@ ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -90,6 +82,7 @@ public slots: void startTargettedServiceDiscovery(); void stopServiceDiscovery(); void serviceDiscovered(const QBluetoothServiceInfo &info); + void leServiceDiscovered(const QLowEnergyServiceInfo &leInfo); void serviceDiscoveryFinished(); void serviceDiscoveryCanceled(); void serviceDiscoveryError(QBluetoothServiceDiscoveryAgent::Error error); diff --git a/tests/bttestui/main.cpp b/tests/bttestui/main.cpp index 964eec59..6543bd7b 100644 --- a/tests/bttestui/main.cpp +++ b/tests/bttestui/main.cpp @@ -5,36 +5,28 @@ ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/bttestui/main.qml b/tests/bttestui/main.qml index 93d943f2..caae54fa 100644 --- a/tests/bttestui/main.qml +++ b/tests/bttestui/main.qml @@ -5,36 +5,28 @@ ** ** This file is part of the QtBluetooth module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/nfctestserver/main.cpp b/tests/nfctestserver/main.cpp index 8f9eca3e..19c7eed8 100644 --- a/tests/nfctestserver/main.cpp +++ b/tests/nfctestserver/main.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/nfctestserver/servercontroller.cpp b/tests/nfctestserver/servercontroller.cpp index 2a6dcce9..32337b58 100644 --- a/tests/nfctestserver/servercontroller.cpp +++ b/tests/nfctestserver/servercontroller.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/nfctestserver/servercontroller.h b/tests/nfctestserver/servercontroller.h index 1104d2a7..7f18dd47 100644 --- a/tests/nfctestserver/servercontroller.h +++ b/tests/nfctestserver/servercontroller.h @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/nfctestserver/servicenames.h b/tests/nfctestserver/servicenames.h index f09f9b9b..d8ad5088 100644 --- a/tests/nfctestserver/servicenames.h +++ b/tests/nfctestserver/servicenames.h @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/tests/nfctestserver/socketcontroller.cpp b/tests/nfctestserver/socketcontroller.cpp index e568d7d7..3b9567c2 100644 --- a/tests/nfctestserver/socketcontroller.cpp +++ b/tests/nfctestserver/socketcontroller.cpp @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -97,7 +89,7 @@ SocketController::~SocketController() void SocketController::connected() { qDebug() << "Client connected"; - const QString data = QLatin1String("HELLO ") + m_service; + const QString data = QStringLiteral("HELLO ") + m_service; switch (m_connectionType) { case StreamConnection: m_socket->write(data.toUtf8() + '\n'); diff --git a/tests/nfctestserver/socketcontroller.h b/tests/nfctestserver/socketcontroller.h index 04583547..02fc3e4f 100644 --- a/tests/nfctestserver/socketcontroller.h +++ b/tests/nfctestserver/socketcontroller.h @@ -1,40 +1,32 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtNfc module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ |