Port simple cases of count() to size()
The count() methods on QByteArray and QString are deprecated. The ones on other Qt containers will likely follow soon, so port them all to size(). The changes which also require int -> qsizetype will come in a follow-up patch. Pick-to: 6.3 Change-Id: I23e364019b9cfc457d93f4a3bb4660fe8d790da8 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
831e364b58
commit
4d975c3ffc
|
@ -77,7 +77,7 @@ Chat::Chat(QWidget *parent)
|
||||||
//! [Construct UI]
|
//! [Construct UI]
|
||||||
|
|
||||||
localAdapters = QBluetoothLocalDevice::allDevices();
|
localAdapters = QBluetoothLocalDevice::allDevices();
|
||||||
if (localAdapters.count() < 2) {
|
if (localAdapters.size() < 2) {
|
||||||
ui->localAdapterBox->setVisible(false);
|
ui->localAdapterBox->setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
//we ignore more than two adapters
|
//we ignore more than two adapters
|
||||||
|
|
|
@ -159,7 +159,7 @@ void ServerAcceptanceThread::javaNewSocket(jobject s)
|
||||||
if (!socket.isValid())
|
if (!socket.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pendingSockets.count() < maxPendingConnections) {
|
if (pendingSockets.size() < maxPendingConnections) {
|
||||||
qCDebug(QT_BT_ANDROID) << "New incoming java socket detected";
|
qCDebug(QT_BT_ANDROID) << "New incoming java socket detected";
|
||||||
pendingSockets.append(socket);
|
pendingSockets.append(socket);
|
||||||
emit newConnection();
|
emit newConnection();
|
||||||
|
|
|
@ -208,7 +208,7 @@ bool HciManager::sendCommand(QBluezConst::OpCodeGroupField ogf, QBluezConst::OpC
|
||||||
quint8 packetType = HCI_COMMAND_PKT;
|
quint8 packetType = HCI_COMMAND_PKT;
|
||||||
hci_command_hdr command = {
|
hci_command_hdr command = {
|
||||||
opCodePack(ogf, ocf),
|
opCodePack(ogf, ocf),
|
||||||
static_cast<uint8_t>(parameters.count())
|
static_cast<uint8_t>(parameters.size())
|
||||||
};
|
};
|
||||||
static_assert(sizeof command == 3, "unexpected struct size");
|
static_assert(sizeof command == 3, "unexpected struct size");
|
||||||
struct iovec iv[3];
|
struct iovec iv[3];
|
||||||
|
@ -219,7 +219,7 @@ bool HciManager::sendCommand(QBluezConst::OpCodeGroupField ogf, QBluezConst::OpC
|
||||||
int ivn = 2;
|
int ivn = 2;
|
||||||
if (!parameters.isEmpty()) {
|
if (!parameters.isEmpty()) {
|
||||||
iv[2].iov_base = const_cast<char *>(parameters.constData()); // const_cast is safe, since iov_base will not get modified.
|
iv[2].iov_base = const_cast<char *>(parameters.constData()); // const_cast is safe, since iov_base will not get modified.
|
||||||
iv[2].iov_len = parameters.count();
|
iv[2].iov_len = parameters.size();
|
||||||
++ivn;
|
++ivn;
|
||||||
}
|
}
|
||||||
while (writev(hciSocket, iv, ivn) < 0) {
|
while (writev(hciSocket, iv, ivn) < 0) {
|
||||||
|
|
|
@ -134,14 +134,14 @@ quint32 qt_countGATTEntries(const QLowEnergyServiceData &data)
|
||||||
{
|
{
|
||||||
const auto maxu32 = std::numeric_limits<quint32>::max();
|
const auto maxu32 = std::numeric_limits<quint32>::max();
|
||||||
// + 1 for a service itself.
|
// + 1 for a service itself.
|
||||||
quint32 nEntries = 1 + quint32(data.includedServices().count());
|
quint32 nEntries = 1 + quint32(data.includedServices().size());
|
||||||
for (const auto &ch : data.characteristics()) {
|
for (const auto &ch : data.characteristics()) {
|
||||||
if (maxu32 - 2 < nEntries)
|
if (maxu32 - 2 < nEntries)
|
||||||
return {};
|
return {};
|
||||||
nEntries += 2;
|
nEntries += 2;
|
||||||
if (maxu32 - ch.descriptors().count() < nEntries)
|
if (maxu32 - ch.descriptors().size() < nEntries)
|
||||||
return {};
|
return {};
|
||||||
nEntries += ch.descriptors().count();
|
nEntries += ch.descriptors().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nEntries;
|
return nEntries;
|
||||||
|
|
|
@ -91,8 +91,8 @@ QByteArray LeCmacCalculator::createFullMessage(const QByteArray &message, quint3
|
||||||
{
|
{
|
||||||
// Spec v4.2, Vol 3, Part H, 2.4.5
|
// Spec v4.2, Vol 3, Part H, 2.4.5
|
||||||
QByteArray fullMessage = message;
|
QByteArray fullMessage = message;
|
||||||
fullMessage.resize(fullMessage.count() + sizeof signCounter);
|
fullMessage.resize(fullMessage.size() + sizeof signCounter);
|
||||||
putBtData(signCounter, fullMessage.data() + message.count());
|
putBtData(signCounter, fullMessage.data() + message.size());
|
||||||
return fullMessage;
|
return fullMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,19 +129,19 @@ quint64 LeCmacCalculator::calculateMac(const QByteArray &message, const quint128
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray messageSwapped(message.count(), Qt::Uninitialized);
|
QByteArray messageSwapped(message.size(), Qt::Uninitialized);
|
||||||
std::reverse_copy(message.begin(), message.end(), messageSwapped.begin());
|
std::reverse_copy(message.begin(), message.end(), messageSwapped.begin());
|
||||||
qint64 totalBytesWritten = 0;
|
qint64 totalBytesWritten = 0;
|
||||||
do {
|
do {
|
||||||
const qint64 bytesWritten = qt_safe_write(cryptoSocket.value(),
|
const qint64 bytesWritten = qt_safe_write(cryptoSocket.value(),
|
||||||
messageSwapped.constData() + totalBytesWritten,
|
messageSwapped.constData() + totalBytesWritten,
|
||||||
messageSwapped.count() - totalBytesWritten);
|
messageSwapped.size() - totalBytesWritten);
|
||||||
if (bytesWritten == -1) {
|
if (bytesWritten == -1) {
|
||||||
qCWarning(QT_BT_BLUEZ) << "writing to crypto socket failed:" << strerror(errno);
|
qCWarning(QT_BT_BLUEZ) << "writing to crypto socket failed:" << strerror(errno);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
totalBytesWritten += bytesWritten;
|
totalBytesWritten += bytesWritten;
|
||||||
} while (totalBytesWritten < messageSwapped.count());
|
} while (totalBytesWritten < messageSwapped.size());
|
||||||
quint64 mac;
|
quint64 mac;
|
||||||
quint8 * const macPtr = reinterpret_cast<quint8 *>(&mac);
|
quint8 * const macPtr = reinterpret_cast<quint8 *>(&mac);
|
||||||
qint64 totalBytesRead = 0;
|
qint64 totalBytesRead = 0;
|
||||||
|
|
|
@ -309,8 +309,8 @@ void QBluetoothDeviceDiscoveryAgentPrivate::deviceFound(const QString &devicePat
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qCDebug(QT_BT_BLUEZ) << "Discovered: " << deviceInfo.name() << deviceInfo.address()
|
qCDebug(QT_BT_BLUEZ) << "Discovered: " << deviceInfo.name() << deviceInfo.address()
|
||||||
<< "Num UUIDs" << deviceInfo.serviceUuids().count()
|
<< "Num UUIDs" << deviceInfo.serviceUuids().size()
|
||||||
<< "total device" << discoveredDevices.count() << "cached"
|
<< "total device" << discoveredDevices.size() << "cached"
|
||||||
<< "RSSI" << deviceInfo.rssi()
|
<< "RSSI" << deviceInfo.rssi()
|
||||||
<< "Num ManufacturerData" << deviceInfo.manufacturerData().size()
|
<< "Num ManufacturerData" << deviceInfo.manufacturerData().size()
|
||||||
<< "Num ServiceData" << deviceInfo.serviceData().size();
|
<< "Num ServiceData" << deviceInfo.serviceData().size();
|
||||||
|
|
|
@ -742,7 +742,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onRfcommServicesReceived(
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(QT_BT_WINDOWS) << "Discovered BT device: " << QString::number(address) << btName
|
qCDebug(QT_BT_WINDOWS) << "Discovered BT device: " << QString::number(address) << btName
|
||||||
<< "Num UUIDs" << uuids.count();
|
<< "Num UUIDs" << uuids.size();
|
||||||
|
|
||||||
QBluetoothDeviceInfo info(QBluetoothAddress(address), btName, classOfDeviceInt);
|
QBluetoothDeviceInfo info(QBluetoothAddress(address), btName, classOfDeviceInt);
|
||||||
info.setCoreConfigurations(QBluetoothDeviceInfo::BaseRateCoreConfiguration);
|
info.setCoreConfigurations(QBluetoothDeviceInfo::BaseRateCoreConfiguration);
|
||||||
|
@ -797,9 +797,9 @@ static void invokeDeviceFoundWithDebug(QWinRTBluetoothDeviceDiscoveryWorker *wor
|
||||||
const QBluetoothDeviceInfo &info)
|
const QBluetoothDeviceInfo &info)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINDOWS) << "Discovered BTLE device: " << info.address() << info.name()
|
qCDebug(QT_BT_WINDOWS) << "Discovered BTLE device: " << info.address() << info.name()
|
||||||
<< "Num UUIDs" << info.serviceUuids().count() << "RSSI:" << info.rssi()
|
<< "Num UUIDs" << info.serviceUuids().size() << "RSSI:" << info.rssi()
|
||||||
<< "Num manufacturer data" << info.manufacturerData().count()
|
<< "Num manufacturer data" << info.manufacturerData().size()
|
||||||
<< "Num service data" << info.serviceData().count();
|
<< "Num service data" << info.serviceData().size();
|
||||||
|
|
||||||
QMetaObject::invokeMethod(worker, "deviceFound", Qt::AutoConnection,
|
QMetaObject::invokeMethod(worker, "deviceFound", Qt::AutoConnection,
|
||||||
Q_ARG(QBluetoothDeviceInfo, info));
|
Q_ARG(QBluetoothDeviceInfo, info));
|
||||||
|
@ -1051,7 +1051,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::registerDevice(const QBluetoothDevic
|
||||||
QList<QBluetoothUuid> uuids = iter->serviceUuids();
|
QList<QBluetoothUuid> uuids = iter->serviceUuids();
|
||||||
uuids.append(info.serviceUuids());
|
uuids.append(info.serviceUuids());
|
||||||
const QSet<QBluetoothUuid> uuidSet(uuids.begin(), uuids.end());
|
const QSet<QBluetoothUuid> uuidSet(uuids.begin(), uuids.end());
|
||||||
if (iter->serviceUuids().count() != uuidSet.count())
|
if (iter->serviceUuids().size() != uuidSet.size())
|
||||||
iter->setServiceUuids(uuidSet.values().toVector());
|
iter->setServiceUuids(uuidSet.values().toVector());
|
||||||
if (iter->coreConfigurations() != info.coreConfigurations())
|
if (iter->coreConfigurations() != info.coreConfigurations())
|
||||||
iter->setCoreConfigurations(QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration);
|
iter->setCoreConfigurations(QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration);
|
||||||
|
|
|
@ -437,7 +437,7 @@ bool QBluetoothDeviceInfo::equals(const QBluetoothDeviceInfo &a, const QBluetoot
|
||||||
return false;
|
return false;
|
||||||
if (a.d_func()->address != b.d_func()->address)
|
if (a.d_func()->address != b.d_func()->address)
|
||||||
return false;
|
return false;
|
||||||
if (a.d_func()->serviceUuids.count() != b.d_func()->serviceUuids.count())
|
if (a.d_func()->serviceUuids.size() != b.d_func()->serviceUuids.size())
|
||||||
return false;
|
return false;
|
||||||
if (a.d_func()->serviceUuids != b.d_func()->serviceUuids)
|
if (a.d_func()->serviceUuids != b.d_func()->serviceUuids)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -219,7 +219,7 @@ QBluetoothAddress QBluetoothServer::serverAddress() const
|
||||||
{
|
{
|
||||||
//Android only supports one local adapter
|
//Android only supports one local adapter
|
||||||
QList<QBluetoothHostInfo> hosts = QBluetoothLocalDevice::allDevices();
|
QList<QBluetoothHostInfo> hosts = QBluetoothLocalDevice::allDevices();
|
||||||
Q_ASSERT(hosts.count() <= 1);
|
Q_ASSERT(hosts.size() <= 1);
|
||||||
|
|
||||||
if (hosts.isEmpty())
|
if (hosts.isEmpty())
|
||||||
return QBluetoothAddress();
|
return QBluetoothAddress();
|
||||||
|
|
|
@ -128,7 +128,7 @@ HRESULT QBluetoothServerPrivate::handleClientConnection(IStreamSocketListener *l
|
||||||
hr = args->get_Socket(&socket);
|
hr = args->get_Socket(&socket);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
QMutexLocker locker(&pendingConnectionsMutex);
|
QMutexLocker locker(&pendingConnectionsMutex);
|
||||||
if (pendingConnections.count() < maxPendingConnections) {
|
if (pendingConnections.size() < maxPendingConnections) {
|
||||||
qCDebug(QT_BT_WINDOWS) << "Accepting connection";
|
qCDebug(QT_BT_WINDOWS) << "Accepting connection";
|
||||||
pendingConnections.append(socket);
|
pendingConnections.append(socket);
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
|
@ -197,7 +197,7 @@ void QBluetoothServer::setMaxPendingConnections(int numConnections)
|
||||||
{
|
{
|
||||||
Q_D(QBluetoothServer);
|
Q_D(QBluetoothServer);
|
||||||
QMutexLocker locker(&d->pendingConnectionsMutex);
|
QMutexLocker locker(&d->pendingConnectionsMutex);
|
||||||
if (d->pendingConnections.count() > numConnections) {
|
if (d->pendingConnections.size() > numConnections) {
|
||||||
qCWarning(QT_BT_WINDOWS) << "There are currently more than" << numConnections << "connections"
|
qCWarning(QT_BT_WINDOWS) << "There are currently more than" << numConnections << "connections"
|
||||||
<< "pending. Number of maximum pending connections was not changed.";
|
<< "pending. Number of maximum pending connections was not changed.";
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -267,7 +267,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_processFetchedUuids(
|
||||||
|
|
||||||
//could not find any service for the current address/device -> go to next one
|
//could not find any service for the current address/device -> go to next one
|
||||||
if (address.isNull() || uuids.isEmpty()) {
|
if (address.isNull() || uuids.isEmpty()) {
|
||||||
if (discoveredDevices.count() == 1) {
|
if (discoveredDevices.size() == 1) {
|
||||||
Q_Q(QBluetoothServiceDiscoveryAgent);
|
Q_Q(QBluetoothServiceDiscoveryAgent);
|
||||||
QTimer::singleShot(4000, q, [this]() {
|
QTimer::singleShot(4000, q, [this]() {
|
||||||
this->_q_fetchUuidsTimeout();
|
this->_q_fetchUuidsTimeout();
|
||||||
|
@ -280,7 +280,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_processFetchedUuids(
|
||||||
|
|
||||||
if (QT_BT_ANDROID().isDebugEnabled()) {
|
if (QT_BT_ANDROID().isDebugEnabled()) {
|
||||||
qCDebug(QT_BT_ANDROID) << "Found UUID for" << address.toString()
|
qCDebug(QT_BT_ANDROID) << "Found UUID for" << address.toString()
|
||||||
<< "\ncount: " << uuids.count();
|
<< "\ncount: " << uuids.size();
|
||||||
|
|
||||||
QString result;
|
QString result;
|
||||||
for (int i = 0; i<uuids.count(); i++)
|
for (int i = 0; i<uuids.count(); i++)
|
||||||
|
@ -303,7 +303,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_processFetchedUuids(
|
||||||
//prefer second uuid set over first
|
//prefer second uuid set over first
|
||||||
populateDiscoveredServices(pair.first, uuids);
|
populateDiscoveredServices(pair.first, uuids);
|
||||||
|
|
||||||
if (discoveredDevices.count() == 1 && sdpCache.isEmpty()) {
|
if (discoveredDevices.size() == 1 && sdpCache.isEmpty()) {
|
||||||
//last regular uuid data set from OS -> we finish here
|
//last regular uuid data set from OS -> we finish here
|
||||||
_q_serviceDiscoveryFinished();
|
_q_serviceDiscoveryFinished();
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_processFetchedUuids(
|
||||||
|
|
||||||
//the discovery on the last device cannot immediately finish
|
//the discovery on the last device cannot immediately finish
|
||||||
//we have to grant the 2 seconds timeout delay
|
//we have to grant the 2 seconds timeout delay
|
||||||
if (discoveredDevices.count() == 1) {
|
if (discoveredDevices.size() == 1) {
|
||||||
Q_Q(QBluetoothServiceDiscoveryAgent);
|
Q_Q(QBluetoothServiceDiscoveryAgent);
|
||||||
QTimer::singleShot(4000, q, [this]() {
|
QTimer::singleShot(4000, q, [this]() {
|
||||||
this->_q_fetchUuidsTimeout();
|
this->_q_fetchUuidsTimeout();
|
||||||
|
|
|
@ -494,7 +494,7 @@ int QBluetoothServiceInfo::protocolServiceMultiplexer() const
|
||||||
|
|
||||||
if (parameters.isEmpty())
|
if (parameters.isEmpty())
|
||||||
return -1;
|
return -1;
|
||||||
else if (parameters.count() == 1)
|
else if (parameters.size() == 1)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return parameters.at(1).toUInt();
|
return parameters.at(1).toUInt();
|
||||||
|
@ -675,7 +675,7 @@ int QBluetoothServiceInfoPrivate::serverChannel() const
|
||||||
|
|
||||||
if (parameters.isEmpty())
|
if (parameters.isEmpty())
|
||||||
return -1;
|
return -1;
|
||||||
else if (parameters.count() == 1)
|
else if (parameters.size() == 1)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return parameters.at(1).toUInt();
|
return parameters.at(1).toUInt();
|
||||||
|
|
|
@ -82,7 +82,7 @@ int channel_or_psm(const QBluetoothServiceInfoPrivate &privateInfo, QBluetoothUu
|
||||||
const auto parameters = privateInfo.protocolDescriptor(uuid);
|
const auto parameters = privateInfo.protocolDescriptor(uuid);
|
||||||
if (parameters.isEmpty())
|
if (parameters.isEmpty())
|
||||||
return -1;
|
return -1;
|
||||||
else if (parameters.count() == 1)
|
else if (parameters.size() == 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return parameters.at(1).toInt();
|
return parameters.at(1).toInt();
|
||||||
|
|
|
@ -257,9 +257,9 @@ static void addServicesData(AdvData &data, const QList<T> &services)
|
||||||
qCWarning(QT_BT_BLUEZ) << "services data does not fit into advertising data packet";
|
qCWarning(QT_BT_BLUEZ) << "services data does not fit into advertising data packet";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const bool dataComplete = maxServices == services.count();
|
const bool dataComplete = maxServices == services.size();
|
||||||
if (!dataComplete) {
|
if (!dataComplete) {
|
||||||
qCWarning(QT_BT_BLUEZ) << "only" << maxServices << "out of" << services.count()
|
qCWarning(QT_BT_BLUEZ) << "only" << maxServices << "out of" << services.size()
|
||||||
<< "services fit into the advertising data";
|
<< "services fit into the advertising data";
|
||||||
}
|
}
|
||||||
data.data[data.length++] = 1 + maxServices * sizeof(T);
|
data.data[data.length++] = 1 + maxServices * sizeof(T);
|
||||||
|
@ -305,7 +305,7 @@ void QLeAdvertiserBluez::setManufacturerData(const QLowEnergyAdvertisingData &sr
|
||||||
{
|
{
|
||||||
if (src.manufacturerId() == QLowEnergyAdvertisingData::invalidManufacturerId())
|
if (src.manufacturerId() == QLowEnergyAdvertisingData::invalidManufacturerId())
|
||||||
return;
|
return;
|
||||||
if (dest.length >= sizeof dest.data - 1 - 1 - 2 - src.manufacturerData().count()) {
|
if (dest.length >= sizeof dest.data - 1 - 1 - 2 - src.manufacturerData().size()) {
|
||||||
qCWarning(QT_BT_BLUEZ) << "manufacturer data does not fit into advertising data packet";
|
qCWarning(QT_BT_BLUEZ) << "manufacturer data does not fit into advertising data packet";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -775,7 +775,7 @@ void QLowEnergyControllerPrivateAndroid::characteristicChanged(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qCDebug(QT_BT_ANDROID) << "Characteristic change notification" << service->uuid
|
qCDebug(QT_BT_ANDROID) << "Characteristic change notification" << service->uuid
|
||||||
<< charHandle << data.toHex() << "length:" << data.count();
|
<< charHandle << data.toHex() << "length:" << data.size();
|
||||||
|
|
||||||
QLowEnergyCharacteristic characteristic = characteristicForHandle(charHandle);
|
QLowEnergyCharacteristic characteristic = characteristicForHandle(charHandle);
|
||||||
if (!characteristic.isValid()) {
|
if (!characteristic.isValid()) {
|
||||||
|
@ -795,7 +795,7 @@ void QLowEnergyControllerPrivateAndroid::serverCharacteristicChanged(
|
||||||
const QJniObject &characteristic, const QByteArray &newValue)
|
const QJniObject &characteristic, const QByteArray &newValue)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_ANDROID) << "Server characteristic change notification"
|
qCDebug(QT_BT_ANDROID) << "Server characteristic change notification"
|
||||||
<< newValue.toHex() << "length:" << newValue.count();
|
<< newValue.toHex() << "length:" << newValue.size();
|
||||||
|
|
||||||
// match characteristic to servicePrivate
|
// match characteristic to servicePrivate
|
||||||
QJniObject service = characteristic.callObjectMethod(
|
QJniObject service = characteristic.callObjectMethod(
|
||||||
|
|
|
@ -206,8 +206,8 @@ template<> void putDataAndIncrement(const QBluetoothUuid &uuid, char *&dst)
|
||||||
template<> void putDataAndIncrement(const QByteArray &value, char *&dst)
|
template<> void putDataAndIncrement(const QByteArray &value, char *&dst)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
memcpy(dst, value.constData(), value.count());
|
memcpy(dst, value.constData(), value.size());
|
||||||
dst += value.count();
|
dst += value.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QLowEnergyControllerPrivateBluez::QLowEnergyControllerPrivateBluez()
|
QLowEnergyControllerPrivateBluez::QLowEnergyControllerPrivateBluez()
|
||||||
|
@ -1320,7 +1320,7 @@ void QLowEnergyControllerPrivateBluez::processReply(
|
||||||
Q_ASSERT(!p.isNull());
|
Q_ASSERT(!p.isNull());
|
||||||
|
|
||||||
if (isErrorResponse) {
|
if (isErrorResponse) {
|
||||||
if (keys.count() == 1) {
|
if (keys.size() == 1) {
|
||||||
// no more descriptors to discover
|
// no more descriptors to discover
|
||||||
readServiceValues(p->uuid, false); //read descriptor values
|
readServiceValues(p->uuid, false); //read descriptor values
|
||||||
} else {
|
} else {
|
||||||
|
@ -1388,7 +1388,7 @@ void QLowEnergyControllerPrivateBluez::processReply(
|
||||||
}
|
}
|
||||||
|
|
||||||
const QLowEnergyHandle nextPotentialHandle = descriptorHandle + 1;
|
const QLowEnergyHandle nextPotentialHandle = descriptorHandle + 1;
|
||||||
if (keys.count() == 1) {
|
if (keys.size() == 1) {
|
||||||
// Reached last characteristic of service
|
// Reached last characteristic of service
|
||||||
|
|
||||||
// The endhandle of a service is always the last handle of
|
// The endhandle of a service is always the last handle of
|
||||||
|
@ -1690,7 +1690,7 @@ void QLowEnergyControllerPrivateBluez::readServiceValues(
|
||||||
request.command = QBluezConst::AttCommand::ATT_OP_READ_REQUEST;
|
request.command = QBluezConst::AttCommand::ATT_OP_READ_REQUEST;
|
||||||
request.reference = pair.second;
|
request.reference = pair.second;
|
||||||
// last entry?
|
// last entry?
|
||||||
request.reference2 = QVariant((bool)(i + 1 == targetHandles.count()));
|
request.reference2 = QVariant((bool)(i + 1 == targetHandles.size()));
|
||||||
openRequests.enqueue(request);
|
openRequests.enqueue(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1912,7 +1912,7 @@ void QLowEnergyControllerPrivateBluez::discoverNextDescriptor(
|
||||||
|
|
||||||
const QLowEnergyHandle charStartHandle = startingHandle;
|
const QLowEnergyHandle charStartHandle = startingHandle;
|
||||||
QLowEnergyHandle charEndHandle = 0;
|
QLowEnergyHandle charEndHandle = 0;
|
||||||
if (pendingCharHandles.count() == 1) //single characteristic
|
if (pendingCharHandles.size() == 1) //single characteristic
|
||||||
charEndHandle = serviceData->endHandle;
|
charEndHandle = serviceData->endHandle;
|
||||||
else
|
else
|
||||||
charEndHandle = pendingCharHandles[1] - 1;
|
charEndHandle = pendingCharHandles[1] - 1;
|
||||||
|
@ -2175,10 +2175,10 @@ bool QLowEnergyControllerPrivateBluez::checkPacketSize(const QByteArray &packet,
|
||||||
{
|
{
|
||||||
if (maxSize == -1)
|
if (maxSize == -1)
|
||||||
maxSize = minSize;
|
maxSize = minSize;
|
||||||
if (Q_LIKELY(packet.count() >= minSize && packet.count() <= maxSize))
|
if (Q_LIKELY(packet.size() >= minSize && packet.size() <= maxSize))
|
||||||
return true;
|
return true;
|
||||||
qCWarning(QT_BT_BLUEZ) << "client request of type" << packet.at(0)
|
qCWarning(QT_BT_BLUEZ) << "client request of type" << packet.at(0)
|
||||||
<< "has unexpected packet size" << packet.count();
|
<< "has unexpected packet size" << packet.size();
|
||||||
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), 0,
|
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), 0,
|
||||||
QBluezConst::AttError::ATT_ERROR_INVALID_PDU);
|
QBluezConst::AttError::ATT_ERROR_INVALID_PDU);
|
||||||
return false;
|
return false;
|
||||||
|
@ -2278,7 +2278,7 @@ void QLowEnergyControllerPrivateBluez::handleFindByTypeValueRequest(const QByteA
|
||||||
const QLowEnergyHandle startingHandle = bt_get_le16(packet.constData() + 1);
|
const QLowEnergyHandle startingHandle = bt_get_le16(packet.constData() + 1);
|
||||||
const QLowEnergyHandle endingHandle = bt_get_le16(packet.constData() + 3);
|
const QLowEnergyHandle endingHandle = bt_get_le16(packet.constData() + 3);
|
||||||
const quint16 type = bt_get_le16(packet.constData() + 5);
|
const quint16 type = bt_get_le16(packet.constData() + 5);
|
||||||
const QByteArray value = QByteArray::fromRawData(packet.constData() + 7, packet.count() - 7);
|
const QByteArray value = QByteArray::fromRawData(packet.constData() + 7, packet.size() - 7);
|
||||||
qCDebug(QT_BT_BLUEZ) << "client sends find by type value request; start:" << startingHandle
|
qCDebug(QT_BT_BLUEZ) << "client sends find by type value request; start:" << startingHandle
|
||||||
<< "end:" << endingHandle << "type:" << type
|
<< "end:" << endingHandle << "type:" << type
|
||||||
<< "value:" << value.toHex();
|
<< "value:" << value.toHex();
|
||||||
|
@ -2316,15 +2316,15 @@ void QLowEnergyControllerPrivateBluez::handleReadByTypeRequest(const QByteArray
|
||||||
const QLowEnergyHandle startingHandle = bt_get_le16(packet.constData() + 1);
|
const QLowEnergyHandle startingHandle = bt_get_le16(packet.constData() + 1);
|
||||||
const QLowEnergyHandle endingHandle = bt_get_le16(packet.constData() + 3);
|
const QLowEnergyHandle endingHandle = bt_get_le16(packet.constData() + 3);
|
||||||
const void * const typeStart = packet.constData() + 5;
|
const void * const typeStart = packet.constData() + 5;
|
||||||
const bool is16BitUuid = packet.count() == 7;
|
const bool is16BitUuid = packet.size() == 7;
|
||||||
const bool is128BitUuid = packet.count() == 21;
|
const bool is128BitUuid = packet.size() == 21;
|
||||||
QBluetoothUuid type;
|
QBluetoothUuid type;
|
||||||
if (is16BitUuid) {
|
if (is16BitUuid) {
|
||||||
type = QBluetoothUuid(bt_get_le16(typeStart));
|
type = QBluetoothUuid(bt_get_le16(typeStart));
|
||||||
} else if (is128BitUuid) {
|
} else if (is128BitUuid) {
|
||||||
type = QBluetoothUuid(convert_uuid128(reinterpret_cast<const quint128 *>(typeStart)));
|
type = QBluetoothUuid(convert_uuid128(reinterpret_cast<const quint128 *>(typeStart)));
|
||||||
} else {
|
} else {
|
||||||
qCWarning(QT_BT_BLUEZ) << "read by type request has invalid packet size" << packet.count();
|
qCWarning(QT_BT_BLUEZ) << "read by type request has invalid packet size" << packet.size();
|
||||||
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), 0,
|
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), 0,
|
||||||
QBluezConst::AttError::ATT_ERROR_INVALID_PDU);
|
QBluezConst::AttError::ATT_ERROR_INVALID_PDU);
|
||||||
return;
|
return;
|
||||||
|
@ -2413,12 +2413,12 @@ void QLowEnergyControllerPrivateBluez::handleReadBlobRequest(const QByteArray &p
|
||||||
permissionsError);
|
permissionsError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (valueOffset > attribute.value.count()) {
|
if (valueOffset > attribute.value.size()) {
|
||||||
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), handle,
|
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), handle,
|
||||||
QBluezConst::AttError::ATT_ERROR_INVALID_OFFSET);
|
QBluezConst::AttError::ATT_ERROR_INVALID_OFFSET);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (attribute.value.count() <= mtuSize - 3) {
|
if (attribute.value.size() <= mtuSize - 3) {
|
||||||
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), handle,
|
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), handle,
|
||||||
QBluezConst::AttError::ATT_ERROR_ATTRIBUTE_NOT_LONG);
|
QBluezConst::AttError::ATT_ERROR_ATTRIBUTE_NOT_LONG);
|
||||||
return;
|
return;
|
||||||
|
@ -2441,7 +2441,7 @@ void QLowEnergyControllerPrivateBluez::handleReadMultipleRequest(const QByteArra
|
||||||
|
|
||||||
if (!checkPacketSize(packet, 5, mtuSize))
|
if (!checkPacketSize(packet, 5, mtuSize))
|
||||||
return;
|
return;
|
||||||
QList<QLowEnergyHandle> handles((packet.count() - 1) / sizeof(QLowEnergyHandle));
|
QList<QLowEnergyHandle> handles((packet.size() - 1) / sizeof(QLowEnergyHandle));
|
||||||
auto *packetPtr = reinterpret_cast<const QLowEnergyHandle *>(packet.constData() + 1);
|
auto *packetPtr = reinterpret_cast<const QLowEnergyHandle *>(packet.constData() + 1);
|
||||||
for (int i = 0; i < handles.count(); ++i, ++packetPtr)
|
for (int i = 0; i < handles.count(); ++i, ++packetPtr)
|
||||||
handles[i] = bt_get_le16(packetPtr);
|
handles[i] = bt_get_le16(packetPtr);
|
||||||
|
@ -2467,7 +2467,7 @@ void QLowEnergyControllerPrivateBluez::handleReadMultipleRequest(const QByteArra
|
||||||
|
|
||||||
// Note: We do not abort if no more values fit into the packet, because we still have to
|
// Note: We do not abort if no more values fit into the packet, because we still have to
|
||||||
// report possible permission errors for the other handles.
|
// report possible permission errors for the other handles.
|
||||||
response += attr.value.left(mtuSize - response.count());
|
response += attr.value.left(mtuSize - response.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(QT_BT_BLUEZ) << "sending response:" << response.toHex();
|
qCDebug(QT_BT_BLUEZ) << "sending response:" << response.toHex();
|
||||||
|
@ -2482,8 +2482,8 @@ void QLowEnergyControllerPrivateBluez::handleReadByGroupTypeRequest(const QByteA
|
||||||
return;
|
return;
|
||||||
const QLowEnergyHandle startingHandle = bt_get_le16(packet.constData() + 1);
|
const QLowEnergyHandle startingHandle = bt_get_le16(packet.constData() + 1);
|
||||||
const QLowEnergyHandle endingHandle = bt_get_le16(packet.constData() + 3);
|
const QLowEnergyHandle endingHandle = bt_get_le16(packet.constData() + 3);
|
||||||
const bool is16BitUuid = packet.count() == 7;
|
const bool is16BitUuid = packet.size() == 7;
|
||||||
const bool is128BitUuid = packet.count() == 21;
|
const bool is128BitUuid = packet.size() == 21;
|
||||||
const void * const typeStart = packet.constData() + 5;
|
const void * const typeStart = packet.constData() + 5;
|
||||||
QBluetoothUuid type;
|
QBluetoothUuid type;
|
||||||
if (is16BitUuid) {
|
if (is16BitUuid) {
|
||||||
|
@ -2492,7 +2492,7 @@ void QLowEnergyControllerPrivateBluez::handleReadByGroupTypeRequest(const QByteA
|
||||||
type = QBluetoothUuid(convert_uuid128(reinterpret_cast<const quint128 *>(typeStart)));
|
type = QBluetoothUuid(convert_uuid128(reinterpret_cast<const quint128 *>(typeStart)));
|
||||||
} else {
|
} else {
|
||||||
qCWarning(QT_BT_BLUEZ) << "read by group type request has invalid packet size"
|
qCWarning(QT_BT_BLUEZ) << "read by group type request has invalid packet size"
|
||||||
<< packet.count();
|
<< packet.size();
|
||||||
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), 0,
|
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), 0,
|
||||||
QBluezConst::AttError::ATT_ERROR_INVALID_PDU);
|
QBluezConst::AttError::ATT_ERROR_INVALID_PDU);
|
||||||
return;
|
return;
|
||||||
|
@ -2580,8 +2580,8 @@ void QLowEnergyControllerPrivateBluez::writeCharacteristicForPeripheral(
|
||||||
const QLowEnergyHandle valueHandle = charData.valueHandle;
|
const QLowEnergyHandle valueHandle = charData.valueHandle;
|
||||||
Q_ASSERT(valueHandle <= lastLocalHandle);
|
Q_ASSERT(valueHandle <= lastLocalHandle);
|
||||||
Attribute &attribute = localAttributes[valueHandle];
|
Attribute &attribute = localAttributes[valueHandle];
|
||||||
if (newValue.count() < attribute.minLength || newValue.count() > attribute.maxLength) {
|
if (newValue.size() < attribute.minLength || newValue.size() > attribute.maxLength) {
|
||||||
qCWarning(QT_BT_BLUEZ) << "ignoring value of invalid length" << newValue.count()
|
qCWarning(QT_BT_BLUEZ) << "ignoring value of invalid length" << newValue.size()
|
||||||
<< "for attribute" << valueHandle;
|
<< "for attribute" << valueHandle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2599,7 +2599,7 @@ void QLowEnergyControllerPrivateBluez::writeCharacteristicForPeripheral(
|
||||||
// Notify/indicate currently connected client.
|
// Notify/indicate currently connected client.
|
||||||
const bool isConnected = state == QLowEnergyController::ConnectedState;
|
const bool isConnected = state == QLowEnergyController::ConnectedState;
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
Q_ASSERT(desc.value.count() == 2);
|
Q_ASSERT(desc.value.size() == 2);
|
||||||
quint16 configValue = bt_get_le16(desc.value.constData());
|
quint16 configValue = bt_get_le16(desc.value.constData());
|
||||||
if (isNotificationEnabled(configValue) && hasNotifyProperty) {
|
if (isNotificationEnabled(configValue) && hasNotifyProperty) {
|
||||||
sendNotification(valueHandle);
|
sendNotification(valueHandle);
|
||||||
|
@ -2636,9 +2636,9 @@ void QLowEnergyControllerPrivateBluez::writeCharacteristicForCentral(const QShar
|
||||||
const QByteArray &newValue,
|
const QByteArray &newValue,
|
||||||
QLowEnergyService::WriteMode mode)
|
QLowEnergyService::WriteMode mode)
|
||||||
{
|
{
|
||||||
QByteArray packet(WRITE_REQUEST_HEADER_SIZE + newValue.count(), Qt::Uninitialized);
|
QByteArray packet(WRITE_REQUEST_HEADER_SIZE + newValue.size(), Qt::Uninitialized);
|
||||||
putBtData(valueHandle, packet.data() + 1);
|
putBtData(valueHandle, packet.data() + 1);
|
||||||
memcpy(packet.data() + 3, newValue.constData(), newValue.count());
|
memcpy(packet.data() + 3, newValue.constData(), newValue.size());
|
||||||
bool writeWithResponse = false;
|
bool writeWithResponse = false;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case QLowEnergyService::WriteWithResponse:
|
case QLowEnergyService::WriteWithResponse:
|
||||||
|
@ -2675,14 +2675,14 @@ void QLowEnergyControllerPrivateBluez::writeCharacteristicForCentral(const QShar
|
||||||
++signingDataIt.value().counter;
|
++signingDataIt.value().counter;
|
||||||
packet = LeCmacCalculator::createFullMessage(packet, signingDataIt.value().counter);
|
packet = LeCmacCalculator::createFullMessage(packet, signingDataIt.value().counter);
|
||||||
const quint64 mac = LeCmacCalculator().calculateMac(packet, signingDataIt.value().key);
|
const quint64 mac = LeCmacCalculator().calculateMac(packet, signingDataIt.value().key);
|
||||||
packet.resize(packet.count() + sizeof mac);
|
packet.resize(packet.size() + sizeof mac);
|
||||||
putBtData(mac, packet.data() + packet.count() - sizeof mac);
|
putBtData(mac, packet.data() + packet.size() - sizeof mac);
|
||||||
storeSignCounter(LocalSigningKey);
|
storeSignCounter(LocalSigningKey);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(QT_BT_BLUEZ) << "Writing characteristic" << Qt::hex << charHandle
|
qCDebug(QT_BT_BLUEZ) << "Writing characteristic" << Qt::hex << charHandle
|
||||||
<< "(size:" << packet.count() << "with response:"
|
<< "(size:" << packet.size() << "with response:"
|
||||||
<< (mode == QLowEnergyService::WriteWithResponse)
|
<< (mode == QLowEnergyService::WriteWithResponse)
|
||||||
<< "signed:" << (mode == QLowEnergyService::WriteSigned) << ")";
|
<< "signed:" << (mode == QLowEnergyService::WriteSigned) << ")";
|
||||||
|
|
||||||
|
@ -2712,8 +2712,8 @@ void QLowEnergyControllerPrivateBluez::writeDescriptorForPeripheral(
|
||||||
{
|
{
|
||||||
Q_ASSERT(descriptorHandle <= lastLocalHandle);
|
Q_ASSERT(descriptorHandle <= lastLocalHandle);
|
||||||
Attribute &attribute = localAttributes[descriptorHandle];
|
Attribute &attribute = localAttributes[descriptorHandle];
|
||||||
if (newValue.count() < attribute.minLength || newValue.count() > attribute.maxLength) {
|
if (newValue.size() < attribute.minLength || newValue.size() > attribute.maxLength) {
|
||||||
qCWarning(QT_BT_BLUEZ) << "invalid value of size" << newValue.count()
|
qCWarning(QT_BT_BLUEZ) << "invalid value of size" << newValue.size()
|
||||||
<< "for attribute" << descriptorHandle;
|
<< "for attribute" << descriptorHandle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2807,8 +2807,8 @@ void QLowEnergyControllerPrivateBluez::handleWriteRequestOrCommand(const QByteAr
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const quint64 macFromClient = getBtData<quint64>(packet.data() + packet.count() - 8);
|
const quint64 macFromClient = getBtData<quint64>(packet.data() + packet.size() - 8);
|
||||||
const bool signatureCorrect = verifyMac(packet.left(packet.count() - 12),
|
const bool signatureCorrect = verifyMac(packet.left(packet.size() - 12),
|
||||||
signingDataIt.value().key, signCounter, macFromClient);
|
signingDataIt.value().key, signCounter, macFromClient);
|
||||||
if (!signatureCorrect) {
|
if (!signatureCorrect) {
|
||||||
qCWarning(QT_BT_BLUEZ) << "Signed Write packet has wrong signature, disconnecting";
|
qCWarning(QT_BT_BLUEZ) << "Signed Write packet has wrong signature, disconnecting";
|
||||||
|
@ -2818,9 +2818,9 @@ void QLowEnergyControllerPrivateBluez::handleWriteRequestOrCommand(const QByteAr
|
||||||
|
|
||||||
signingDataIt.value().counter = signCounter;
|
signingDataIt.value().counter = signCounter;
|
||||||
storeSignCounter(RemoteSigningKey);
|
storeSignCounter(RemoteSigningKey);
|
||||||
valueLength = packet.count() - 15;
|
valueLength = packet.size() - 15;
|
||||||
} else {
|
} else {
|
||||||
valueLength = packet.count() - 3;
|
valueLength = packet.size() - 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valueLength > attribute.maxLength) {
|
if (valueLength > attribute.maxLength) {
|
||||||
|
@ -2872,7 +2872,7 @@ void QLowEnergyControllerPrivateBluez::handlePrepareWriteRequest(const QByteArra
|
||||||
permissionsError);
|
permissionsError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (openPrepareWriteRequests.count() >= maxPrepareQueueSize) {
|
if (openPrepareWriteRequests.size() >= maxPrepareQueueSize) {
|
||||||
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), handle,
|
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)), handle,
|
||||||
QBluezConst::AttError::ATT_ERROR_PREPARE_QUEUE_FULL);
|
QBluezConst::AttError::ATT_ERROR_PREPARE_QUEUE_FULL);
|
||||||
return;
|
return;
|
||||||
|
@ -2904,13 +2904,13 @@ void QLowEnergyControllerPrivateBluez::handleExecuteWriteRequest(const QByteArra
|
||||||
if (!cancel) {
|
if (!cancel) {
|
||||||
for (const WriteRequest &request : qAsConst(requests)) {
|
for (const WriteRequest &request : qAsConst(requests)) {
|
||||||
Attribute &attribute = localAttributes[request.handle];
|
Attribute &attribute = localAttributes[request.handle];
|
||||||
if (request.valueOffset > attribute.value.count()) {
|
if (request.valueOffset > attribute.value.size()) {
|
||||||
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)),
|
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)),
|
||||||
request.handle, QBluezConst::AttError::ATT_ERROR_INVALID_OFFSET);
|
request.handle, QBluezConst::AttError::ATT_ERROR_INVALID_OFFSET);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const QByteArray newValue = attribute.value.left(request.valueOffset) + request.value;
|
const QByteArray newValue = attribute.value.left(request.valueOffset) + request.value;
|
||||||
if (newValue.count() > attribute.maxLength) {
|
if (newValue.size() > attribute.maxLength) {
|
||||||
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)),
|
sendErrorResponse(static_cast<QBluezConst::AttCommand>(packet.at(0)),
|
||||||
request.handle,
|
request.handle,
|
||||||
QBluezConst::AttError::ATT_ERROR_INVAL_ATTR_VALUE_LEN);
|
QBluezConst::AttError::ATT_ERROR_INVAL_ATTR_VALUE_LEN);
|
||||||
|
@ -3142,7 +3142,7 @@ void QLowEnergyControllerPrivateBluez::storeClientConfigurations()
|
||||||
QList<ClientConfigurationData> clientConfigs;
|
QList<ClientConfigurationData> clientConfigs;
|
||||||
const QList<TempClientConfigurationData> &tempConfigList = gatherClientConfigData();
|
const QList<TempClientConfigurationData> &tempConfigList = gatherClientConfigData();
|
||||||
for (const auto &tempConfigData : tempConfigList) {
|
for (const auto &tempConfigData : tempConfigList) {
|
||||||
Q_ASSERT(tempConfigData.descData->value.count() == 2);
|
Q_ASSERT(tempConfigData.descData->value.size() == 2);
|
||||||
const quint16 value = bt_get_le16(tempConfigData.descData->value.constData());
|
const quint16 value = bt_get_le16(tempConfigData.descData->value.constData());
|
||||||
if (value != 0) {
|
if (value != 0) {
|
||||||
clientConfigs << ClientConfigurationData(tempConfigData.charValueHandle,
|
clientConfigs << ClientConfigurationData(tempConfigData.charValueHandle,
|
||||||
|
@ -3163,7 +3163,7 @@ void QLowEnergyControllerPrivateBluez::restoreClientConfigurations()
|
||||||
bool wasRestored = false;
|
bool wasRestored = false;
|
||||||
for (const auto &restoredData : restoredClientConfigs) {
|
for (const auto &restoredData : restoredClientConfigs) {
|
||||||
if (restoredData.charValueHandle == tempConfigData.charValueHandle) {
|
if (restoredData.charValueHandle == tempConfigData.charValueHandle) {
|
||||||
Q_ASSERT(tempConfigData.descData->value.count() == 2);
|
Q_ASSERT(tempConfigData.descData->value.size() == 2);
|
||||||
putBtData(restoredData.configValue, tempConfigData.descData->value.data());
|
putBtData(restoredData.configValue, tempConfigData.descData->value.data());
|
||||||
wasRestored = true;
|
wasRestored = true;
|
||||||
if (restoredData.charValueWasUpdated) {
|
if (restoredData.charValueWasUpdated) {
|
||||||
|
@ -3206,16 +3206,16 @@ void QLowEnergyControllerPrivateBluez::loadSigningDataIfNecessary(SigningKeyType
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const QByteArray keyData = QByteArray::fromHex(keyString);
|
const QByteArray keyData = QByteArray::fromHex(keyString);
|
||||||
if (keyData.count() != int(sizeof(quint128))) {
|
if (keyData.size() != int(sizeof(quint128))) {
|
||||||
qCWarning(QT_BT_BLUEZ) << "Signing key in settings file has invalid size"
|
qCWarning(QT_BT_BLUEZ) << "Signing key in settings file has invalid size"
|
||||||
<< keyString.count();
|
<< keyString.size();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qCDebug(QT_BT_BLUEZ) << "CSRK of peer device is" << keyString;
|
qCDebug(QT_BT_BLUEZ) << "CSRK of peer device is" << keyString;
|
||||||
const quint32 counter = settings.value(QLatin1String("Counter"), 0).toUInt();
|
const quint32 counter = settings.value(QLatin1String("Counter"), 0).toUInt();
|
||||||
quint128 csrk;
|
quint128 csrk;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
memcpy(csrk.data, keyData.constData(), keyData.count());
|
memcpy(csrk.data, keyData.constData(), keyData.size());
|
||||||
signingData.insert(remoteDevice.toUInt64(), SigningData(csrk, counter - 1));
|
signingData.insert(remoteDevice.toUInt64(), SigningData(csrk, counter - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3302,7 +3302,7 @@ void QLowEnergyControllerPrivateBluez::addToGenericAttributeList(const QLowEnerg
|
||||||
|
|
||||||
// Characteristic declaration;
|
// Characteristic declaration;
|
||||||
attribute.handle = ++currentHandle;
|
attribute.handle = ++currentHandle;
|
||||||
attribute.groupEndHandle = attribute.handle + 1 + cd.descriptors().count();
|
attribute.groupEndHandle = attribute.handle + 1 + cd.descriptors().size();
|
||||||
attribute.type = QBluetoothUuid(GATT_CHARACTERISTIC);
|
attribute.type = QBluetoothUuid(GATT_CHARACTERISTIC);
|
||||||
attribute.properties = QLowEnergyCharacteristic::Read;
|
attribute.properties = QLowEnergyCharacteristic::Read;
|
||||||
attribute.value.resize(1 + sizeof(QLowEnergyHandle) + cd.uuid().minimumSize());
|
attribute.value.resize(1 + sizeof(QLowEnergyHandle) + cd.uuid().minimumSize());
|
||||||
|
@ -3366,10 +3366,10 @@ void QLowEnergyControllerPrivateBluez::addToGenericAttributeList(const QLowEnerg
|
||||||
}
|
}
|
||||||
|
|
||||||
attribute.value = dd.value();
|
attribute.value = dd.value();
|
||||||
if (attribute.value.count() < attribute.minLength
|
if (attribute.value.size() < attribute.minLength
|
||||||
|| attribute.value.count() > attribute.maxLength) {
|
|| attribute.value.size() > attribute.maxLength) {
|
||||||
qCWarning(QT_BT_BLUEZ) << "attribute of type" << attribute.type
|
qCWarning(QT_BT_BLUEZ) << "attribute of type" << attribute.type
|
||||||
<< "has invalid length of" << attribute.value.count()
|
<< "has invalid length of" << attribute.value.size()
|
||||||
<< "bytes";
|
<< "bytes";
|
||||||
attribute.value = QByteArray(attribute.minLength, 0);
|
attribute.value = QByteArray(attribute.minLength, 0);
|
||||||
}
|
}
|
||||||
|
@ -3407,7 +3407,7 @@ void QLowEnergyControllerPrivateBluez::ensureUniformUuidSizes(QList<Attribute> &
|
||||||
void QLowEnergyControllerPrivateBluez::ensureUniformValueSizes(QList<Attribute> &attributes)
|
void QLowEnergyControllerPrivateBluez::ensureUniformValueSizes(QList<Attribute> &attributes)
|
||||||
{
|
{
|
||||||
ensureUniformAttributes(attributes,
|
ensureUniformAttributes(attributes,
|
||||||
[](const Attribute &attr) { return attr.value.count(); });
|
[](const Attribute &attr) { return attr.value.size(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QLowEnergyControllerPrivateBluez::Attribute>
|
QList<QLowEnergyControllerPrivateBluez::Attribute>
|
||||||
|
|
|
@ -873,7 +873,7 @@ void QLowEnergyControllerPrivateWinRT::registerForValueChanges(const QBluetoothU
|
||||||
|
|
||||||
void QLowEnergyControllerPrivateWinRT::unregisterFromValueChanges()
|
void QLowEnergyControllerPrivateWinRT::unregisterFromValueChanges()
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINDOWS) << "Unregistering " << mValueChangedTokens.count() << " value change tokens";
|
qCDebug(QT_BT_WINDOWS) << "Unregistering " << mValueChangedTokens.size() << " value change tokens";
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
for (const ValueChangedEntry &entry : qAsConst(mValueChangedTokens)) {
|
for (const ValueChangedEntry &entry : qAsConst(mValueChangedTokens)) {
|
||||||
if (!entry.characteristic) {
|
if (!entry.characteristic) {
|
||||||
|
|
|
@ -292,7 +292,7 @@ QLowEnergyService *QLowEnergyControllerPrivate::addServiceHelper(
|
||||||
// Spec v4.2, Vol 3, Part G, Section 3.
|
// Spec v4.2, Vol 3, Part G, Section 3.
|
||||||
const QLowEnergyHandle oldLastHandle = this->lastLocalHandle;
|
const QLowEnergyHandle oldLastHandle = this->lastLocalHandle;
|
||||||
servicePrivate->startHandle = ++this->lastLocalHandle; // Service declaration.
|
servicePrivate->startHandle = ++this->lastLocalHandle; // Service declaration.
|
||||||
this->lastLocalHandle += servicePrivate->includedServices.count(); // Include declarations.
|
this->lastLocalHandle += servicePrivate->includedServices.size(); // Include declarations.
|
||||||
const QList<QLowEnergyCharacteristicData> characteristics = service.characteristics();
|
const QList<QLowEnergyCharacteristicData> characteristics = service.characteristics();
|
||||||
for (const QLowEnergyCharacteristicData &cd : characteristics) {
|
for (const QLowEnergyCharacteristicData &cd : characteristics) {
|
||||||
const QLowEnergyHandle declHandle = ++this->lastLocalHandle;
|
const QLowEnergyHandle declHandle = ++this->lastLocalHandle;
|
||||||
|
|
|
@ -406,7 +406,7 @@ bool QNdefFilter::match(const QNdefMessage &message) const
|
||||||
|
|
||||||
if (matched) {
|
if (matched) {
|
||||||
// Check that the occurrences match [min; max] range.
|
// Check that the occurrences match [min; max] range.
|
||||||
for (qsizetype i = 0; i < mergedRecords.count(); ++i) {
|
for (qsizetype i = 0; i < mergedRecords.size(); ++i) {
|
||||||
const auto &rec = mergedRecords.at(i);
|
const auto &rec = mergedRecords.at(i);
|
||||||
totalCount += counts[i];
|
totalCount += counts[i];
|
||||||
if (counts[i] < rec.minimum || counts[i] > rec.maximum) {
|
if (counts[i] < rec.minimum || counts[i] > rec.maximum) {
|
||||||
|
@ -517,7 +517,7 @@ QNdefFilter::Record QNdefFilter::recordAt(qsizetype i) const
|
||||||
*/
|
*/
|
||||||
qsizetype QNdefFilter::recordCount() const
|
qsizetype QNdefFilter::recordCount() const
|
||||||
{
|
{
|
||||||
return d->filterRecords.count();
|
return d->filterRecords.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
|
@ -279,12 +279,12 @@ bool QNdefMessage::operator==(const QNdefMessage &other) const
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// compare empty to really empty
|
// compare empty to really empty
|
||||||
if (isEmpty() && other.count() == 1 && other.first().typeNameFormat() == QNdefRecord::Empty)
|
if (isEmpty() && other.size() == 1 && other.first().typeNameFormat() == QNdefRecord::Empty)
|
||||||
return true;
|
return true;
|
||||||
if (other.isEmpty() && count() == 1 && first().typeNameFormat() == QNdefRecord::Empty)
|
if (other.isEmpty() && size() == 1 && first().typeNameFormat() == QNdefRecord::Empty)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (count() != other.count())
|
if (size() != other.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i = 0; i < count(); ++i) {
|
for (int i = 0; i < count(); ++i) {
|
||||||
|
@ -316,7 +316,7 @@ QByteArray QNdefMessage::toByteArray() const
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
flags |= 0x80;
|
flags |= 0x80;
|
||||||
if (i == count() - 1)
|
if (i == size() - 1)
|
||||||
flags |= 0x40;
|
flags |= 0x40;
|
||||||
|
|
||||||
// cf (chunked records) not supported yet
|
// cf (chunked records) not supported yet
|
||||||
|
|
|
@ -97,7 +97,7 @@ void tst_QBluetoothDeviceDiscoveryAgent::initTestCase()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<QBluetoothDeviceInfo>();
|
qRegisterMetaType<QBluetoothDeviceInfo>();
|
||||||
|
|
||||||
noOfLocalDevices = QBluetoothLocalDevice::allDevices().count();
|
noOfLocalDevices = QBluetoothLocalDevice::allDevices().size();
|
||||||
|
|
||||||
if (!noOfLocalDevices)
|
if (!noOfLocalDevices)
|
||||||
return;
|
return;
|
||||||
|
@ -190,7 +190,7 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
|
||||||
// we should not be active anymore
|
// we should not be active anymore
|
||||||
QVERIFY(!discoveryAgent.isActive());
|
QVERIFY(!discoveryAgent.isActive());
|
||||||
QVERIFY(errorSpy.isEmpty());
|
QVERIFY(errorSpy.isEmpty());
|
||||||
QCOMPARE(cancelSpy.count(), 1);
|
QCOMPARE(cancelSpy.size(), 1);
|
||||||
cancelSpy.clear();
|
cancelSpy.clear();
|
||||||
// Starting case 2: start-start-stop, expecting cancel signal
|
// Starting case 2: start-start-stop, expecting cancel signal
|
||||||
discoveryAgent.start();
|
discoveryAgent.start();
|
||||||
|
@ -214,7 +214,7 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
|
||||||
// we should not be active anymore
|
// we should not be active anymore
|
||||||
QVERIFY(!discoveryAgent.isActive());
|
QVERIFY(!discoveryAgent.isActive());
|
||||||
QVERIFY(errorSpy.isEmpty());
|
QVERIFY(errorSpy.isEmpty());
|
||||||
QVERIFY(cancelSpy.count() == 1);
|
QVERIFY(cancelSpy.size() == 1);
|
||||||
cancelSpy.clear();
|
cancelSpy.clear();
|
||||||
|
|
||||||
// Starting case 3: stop
|
// Starting case 3: stop
|
||||||
|
@ -246,7 +246,7 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
|
||||||
// cancel current request.
|
// cancel current request.
|
||||||
discoveryAgent.stop();
|
discoveryAgent.stop();
|
||||||
//should only have triggered cancel() if stop didn't involve the event loop
|
//should only have triggered cancel() if stop didn't involve the event loop
|
||||||
if (cancelSpy.count() == 1) immediateSignal = true;
|
if (cancelSpy.size() == 1) immediateSignal = true;
|
||||||
|
|
||||||
// start a new one
|
// start a new one
|
||||||
discoveryAgent.start();
|
discoveryAgent.start();
|
||||||
|
@ -256,7 +256,7 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
|
||||||
// stop
|
// stop
|
||||||
discoveryAgent.stop();
|
discoveryAgent.stop();
|
||||||
if (immediateSignal)
|
if (immediateSignal)
|
||||||
QVERIFY(cancelSpy.count() == 2);
|
QVERIFY(cancelSpy.size() == 2);
|
||||||
|
|
||||||
// Wait for up to MaxWaitForCancelTime for the cancel to finish
|
// Wait for up to MaxWaitForCancelTime for the cancel to finish
|
||||||
waitTime = MaxWaitForCancelTime;
|
waitTime = MaxWaitForCancelTime;
|
||||||
|
@ -270,9 +270,9 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
|
||||||
// should only have 1 cancel
|
// should only have 1 cancel
|
||||||
|
|
||||||
if (immediateSignal)
|
if (immediateSignal)
|
||||||
QVERIFY(cancelSpy.count() == 2);
|
QVERIFY(cancelSpy.size() == 2);
|
||||||
else
|
else
|
||||||
QVERIFY(cancelSpy.count() == 1);
|
QVERIFY(cancelSpy.size() == 1);
|
||||||
cancelSpy.clear();
|
cancelSpy.clear();
|
||||||
|
|
||||||
// Starting case 5: start-stop-start: expecting finished signal & no cancel
|
// Starting case 5: start-stop-start: expecting finished signal & no cancel
|
||||||
|
@ -298,7 +298,7 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
|
||||||
QVERIFY(!discoveryAgent.isActive());
|
QVERIFY(!discoveryAgent.isActive());
|
||||||
QVERIFY(errorSpy.isEmpty());
|
QVERIFY(errorSpy.isEmpty());
|
||||||
// should only have 1 cancel
|
// should only have 1 cancel
|
||||||
QVERIFY(finishedSpy.count() == 1);
|
QVERIFY(finishedSpy.size() == 1);
|
||||||
|
|
||||||
// On OS X, stop is synchronous (signal will be emitted immediately).
|
// On OS X, stop is synchronous (signal will be emitted immediately).
|
||||||
if (!immediateSignal)
|
if (!immediateSignal)
|
||||||
|
@ -356,7 +356,7 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_deviceDiscovery()
|
||||||
QVERIFY(!discoveryAgent.isActive());
|
QVERIFY(!discoveryAgent.isActive());
|
||||||
qDebug() << "Scan time left:" << scanTime;
|
qDebug() << "Scan time left:" << scanTime;
|
||||||
// Expect finished signal with no error
|
// Expect finished signal with no error
|
||||||
QVERIFY(finishedSpy.count() == 1);
|
QVERIFY(finishedSpy.size() == 1);
|
||||||
QVERIFY(errorSpy.isEmpty());
|
QVERIFY(errorSpy.isEmpty());
|
||||||
QVERIFY(discoveryAgent.error() == discoveryAgent.NoError);
|
QVERIFY(discoveryAgent.error() == discoveryAgent.NoError);
|
||||||
QVERIFY(discoveryAgent.errorString().isEmpty());
|
QVERIFY(discoveryAgent.errorString().isEmpty());
|
||||||
|
@ -365,7 +365,7 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_deviceDiscovery()
|
||||||
// discoveredSpy might have more events as some devices are found multiple times,
|
// discoveredSpy might have more events as some devices are found multiple times,
|
||||||
// leading to messages like
|
// leading to messages like
|
||||||
// "Almost Duplicate "88:C6:26:F5:3E:E2" "88-C6-26-F5-3E-E2" - replacing in place"
|
// "Almost Duplicate "88:C6:26:F5:3E:E2" "88-C6-26-F5-3E-E2" - replacing in place"
|
||||||
QVERIFY(discoveredSpy.count() >= discoveryAgent.discoveredDevices().length());
|
QVERIFY(discoveredSpy.size() >= discoveryAgent.discoveredDevices().size());
|
||||||
// verify that there really was some devices in the array
|
// verify that there really was some devices in the array
|
||||||
|
|
||||||
const QString remote = qEnvironmentVariable("BT_TEST_DEVICE");
|
const QString remote = qEnvironmentVariable("BT_TEST_DEVICE");
|
||||||
|
@ -482,7 +482,7 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_discoveryMethods()
|
||||||
QVERIFY(supportedMethods == QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
|
QVERIFY(supportedMethods == QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
|
||||||
QCOMPARE(agent.error(), QBluetoothDeviceDiscoveryAgent::UnsupportedDiscoveryMethod);
|
QCOMPARE(agent.error(), QBluetoothDeviceDiscoveryAgent::UnsupportedDiscoveryMethod);
|
||||||
} else {
|
} else {
|
||||||
QVERIFY(finishedSpy.count() == 1);
|
QVERIFY(finishedSpy.size() == 1);
|
||||||
QVERIFY(agent.error() == QBluetoothDeviceDiscoveryAgent::NoError);
|
QVERIFY(agent.error() == QBluetoothDeviceDiscoveryAgent::NoError);
|
||||||
QVERIFY(agent.errorString().isEmpty());
|
QVERIFY(agent.errorString().isEmpty());
|
||||||
|
|
||||||
|
|
|
@ -457,7 +457,7 @@ void tst_QBluetoothDeviceInfo::tst_serviceUuids()
|
||||||
deviceInfo.setServiceUuids(servicesList);
|
deviceInfo.setServiceUuids(servicesList);
|
||||||
QVERIFY(!deviceInfo.serviceUuids().isEmpty());
|
QVERIFY(!deviceInfo.serviceUuids().isEmpty());
|
||||||
deviceInfo.setServiceUuids(QList<QBluetoothUuid>());
|
deviceInfo.setServiceUuids(QList<QBluetoothUuid>());
|
||||||
QCOMPARE(deviceInfo.serviceUuids().count(), 0);
|
QCOMPARE(deviceInfo.serviceUuids().size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QBluetoothDeviceInfo::tst_cached()
|
void tst_QBluetoothDeviceInfo::tst_cached()
|
||||||
|
@ -528,8 +528,8 @@ void tst_QBluetoothDeviceInfo::tst_manufacturerData()
|
||||||
QVERIFY(!info.setManufacturerData(manufacturerAVM, QByteArray::fromHex("ABCD")));
|
QVERIFY(!info.setManufacturerData(manufacturerAVM, QByteArray::fromHex("ABCD")));
|
||||||
QCOMPARE(info.manufacturerData(manufacturerAVM), QByteArray::fromHex("ABCD"));
|
QCOMPARE(info.manufacturerData(manufacturerAVM), QByteArray::fromHex("ABCD"));
|
||||||
auto temp = info.manufacturerData();
|
auto temp = info.manufacturerData();
|
||||||
QCOMPARE(temp.keys().count(), 1);
|
QCOMPARE(temp.keys().size(), 1);
|
||||||
QCOMPARE(temp.values().count(), 1);
|
QCOMPARE(temp.values().size(), 1);
|
||||||
QCOMPARE(temp.values(), QList<QByteArray>() << QByteArray::fromHex("ABCD"));
|
QCOMPARE(temp.values(), QList<QByteArray>() << QByteArray::fromHex("ABCD"));
|
||||||
|
|
||||||
QVERIFY(info.setManufacturerData(manufacturerAVM, QByteArray::fromHex("CDEF")));
|
QVERIFY(info.setManufacturerData(manufacturerAVM, QByteArray::fromHex("CDEF")));
|
||||||
|
@ -537,8 +537,8 @@ void tst_QBluetoothDeviceInfo::tst_manufacturerData()
|
||||||
QVERIFY(!info.setManufacturerData(manufacturerAVM, QByteArray::fromHex("CDEF")));
|
QVERIFY(!info.setManufacturerData(manufacturerAVM, QByteArray::fromHex("CDEF")));
|
||||||
|
|
||||||
temp = info.manufacturerData();
|
temp = info.manufacturerData();
|
||||||
QCOMPARE(temp.keys().count(), 2);
|
QCOMPARE(temp.keys().size(), 2);
|
||||||
QCOMPARE(temp.values().count(), 2);
|
QCOMPARE(temp.values().size(), 2);
|
||||||
auto list = temp.values();
|
auto list = temp.values();
|
||||||
|
|
||||||
QCOMPARE(QSet<QByteArray> (list.begin(), list.end()),
|
QCOMPARE(QSet<QByteArray> (list.begin(), list.end()),
|
||||||
|
|
|
@ -75,7 +75,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
tst_QBluetoothLocalDevice::tst_QBluetoothLocalDevice()
|
tst_QBluetoothLocalDevice::tst_QBluetoothLocalDevice()
|
||||||
: numDevices(QBluetoothLocalDevice::allDevices().count()), expectRemoteDevice(false)
|
: numDevices(QBluetoothLocalDevice::allDevices().size()),
|
||||||
|
expectRemoteDevice(false)
|
||||||
{
|
{
|
||||||
const QString remote = qgetenv("BT_TEST_DEVICE");
|
const QString remote = qgetenv("BT_TEST_DEVICE");
|
||||||
if (!remote.isEmpty()) {
|
if (!remote.isEmpty()) {
|
||||||
|
|
|
@ -133,7 +133,7 @@ void tst_QBluetoothServiceDiscoveryAgent::initTestCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expect finished signal with no error
|
// Expect finished signal with no error
|
||||||
QVERIFY(finishedSpy.count() == 1);
|
QVERIFY(finishedSpy.size() == 1);
|
||||||
QVERIFY(errorSpy.isEmpty());
|
QVERIFY(errorSpy.isEmpty());
|
||||||
|
|
||||||
devices = discoveryAgent.discoveredDevices();
|
devices = discoveryAgent.discoveredDevices();
|
||||||
|
@ -153,12 +153,12 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscoveryStop()
|
||||||
discoveryAgent.start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
|
discoveryAgent.start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
|
||||||
QVERIFY(discoveryAgent.isActive());
|
QVERIFY(discoveryAgent.isActive());
|
||||||
discoveryAgent.stop();
|
discoveryAgent.stop();
|
||||||
QTRY_COMPARE(canceledSpy.count(), 1);
|
QTRY_COMPARE(canceledSpy.size(), 1);
|
||||||
QVERIFY(!discoveryAgent.isActive());
|
QVERIFY(!discoveryAgent.isActive());
|
||||||
// Wait a bit to see that there are no latent signals
|
// Wait a bit to see that there are no latent signals
|
||||||
QTest::qWait(200);
|
QTest::qWait(200);
|
||||||
QCOMPARE(canceledSpy.count(), 1);
|
QCOMPARE(canceledSpy.size(), 1);
|
||||||
QCOMPARE(finishedSpy.count(), 0);
|
QCOMPARE(finishedSpy.size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -431,13 +431,13 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
|
||||||
|
|
||||||
// Expect finished signal with no error
|
// Expect finished signal with no error
|
||||||
if (scanTime)
|
if (scanTime)
|
||||||
QVERIFY(finishedSpy.count() == 1);
|
QVERIFY(finishedSpy.size() == 1);
|
||||||
|
|
||||||
QVERIFY(errorSpy.isEmpty());
|
QVERIFY(errorSpy.isEmpty());
|
||||||
|
|
||||||
//if (!discoveryAgent.discoveredServices().isEmpty() && expected_failures++ <2){
|
//if (!discoveryAgent.discoveredServices().isEmpty() && expected_failures++ <2){
|
||||||
if (discoveredSpy.isEmpty()) {
|
if (discoveredSpy.isEmpty()) {
|
||||||
qDebug() << "Device failed to return any results, skipping device" << discoveryAgent.discoveredServices().count();
|
qDebug() << "Device failed to return any results, skipping device" << discoveryAgent.discoveredServices().size();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,13 +127,13 @@ void tst_QBluetoothServiceInfo::tst_construction()
|
||||||
QCOMPARE(serviceInfo.serviceDescription(), QString());
|
QCOMPARE(serviceInfo.serviceDescription(), QString());
|
||||||
QCOMPARE(serviceInfo.serviceProvider(), QString());
|
QCOMPARE(serviceInfo.serviceProvider(), QString());
|
||||||
QCOMPARE(serviceInfo.serviceUuid(), QBluetoothUuid());
|
QCOMPARE(serviceInfo.serviceUuid(), QBluetoothUuid());
|
||||||
QCOMPARE(serviceInfo.serviceClassUuids().count(), 0);
|
QCOMPARE(serviceInfo.serviceClassUuids().size(), 0);
|
||||||
QCOMPARE(serviceInfo.attributes().count(), 0);
|
QCOMPARE(serviceInfo.attributes().size(), 0);
|
||||||
QCOMPARE(serviceInfo.serverChannel(), -1);
|
QCOMPARE(serviceInfo.serverChannel(), -1);
|
||||||
QCOMPARE(serviceInfo.protocolServiceMultiplexer(), -1);
|
QCOMPARE(serviceInfo.protocolServiceMultiplexer(), -1);
|
||||||
|
|
||||||
for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids))
|
for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids))
|
||||||
QCOMPARE(serviceInfo.protocolDescriptor(u).count(), 0);
|
QCOMPARE(serviceInfo.protocolDescriptor(u).size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -167,9 +167,9 @@ void tst_QBluetoothServiceInfo::tst_construction()
|
||||||
QCOMPARE(serviceInfo.device().address(), alternatedeviceInfo.address());
|
QCOMPARE(serviceInfo.device().address(), alternatedeviceInfo.address());
|
||||||
|
|
||||||
for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids))
|
for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids))
|
||||||
QCOMPARE(serviceInfo.protocolDescriptor(u).count(), 0);
|
QCOMPARE(serviceInfo.protocolDescriptor(u).size(), 0);
|
||||||
for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids))
|
for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids))
|
||||||
QCOMPARE(copyInfo.protocolDescriptor(u).count(), 0);
|
QCOMPARE(copyInfo.protocolDescriptor(u).size(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,20 +396,20 @@ void tst_QBluetoothServiceInfo::tst_assignment()
|
||||||
void tst_QBluetoothServiceInfo::tst_serviceClassUuids()
|
void tst_QBluetoothServiceInfo::tst_serviceClassUuids()
|
||||||
{
|
{
|
||||||
QBluetoothServiceInfo info;
|
QBluetoothServiceInfo info;
|
||||||
QCOMPARE(info.serviceClassUuids().count(), 0);
|
QCOMPARE(info.serviceClassUuids().size(), 0);
|
||||||
|
|
||||||
QBluetoothServiceInfo::Sequence classIds;
|
QBluetoothServiceInfo::Sequence classIds;
|
||||||
classIds << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::SerialPort));
|
classIds << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::SerialPort));
|
||||||
QCOMPARE(classIds.count(), 1);
|
QCOMPARE(classIds.size(), 1);
|
||||||
|
|
||||||
QBluetoothUuid uuid(QString("e8e10f95-1a70-4b27-9ccf-02010264e9c8"));
|
QBluetoothUuid uuid(QString("e8e10f95-1a70-4b27-9ccf-02010264e9c8"));
|
||||||
classIds.prepend(QVariant::fromValue(uuid));
|
classIds.prepend(QVariant::fromValue(uuid));
|
||||||
QCOMPARE(classIds.count(), 2);
|
QCOMPARE(classIds.size(), 2);
|
||||||
QCOMPARE(classIds.at(0).value<QBluetoothUuid>(), uuid);
|
QCOMPARE(classIds.at(0).value<QBluetoothUuid>(), uuid);
|
||||||
|
|
||||||
info.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classIds);
|
info.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classIds);
|
||||||
QList<QBluetoothUuid> svclids = info.serviceClassUuids();
|
QList<QBluetoothUuid> svclids = info.serviceClassUuids();
|
||||||
QCOMPARE(svclids.count(), 2);
|
QCOMPARE(svclids.size(), 2);
|
||||||
QCOMPARE(svclids.at(0), uuid);
|
QCOMPARE(svclids.at(0), uuid);
|
||||||
QCOMPARE(svclids.at(1), QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::SerialPort));
|
QCOMPARE(svclids.at(1), QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::SerialPort));
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ void tst_QBluetoothSocket::tst_serviceConnection()
|
||||||
|
|
||||||
socket.connectToService(remoteServiceInfo);
|
socket.connectToService(remoteServiceInfo);
|
||||||
|
|
||||||
QCOMPARE(stateSpy.count(), 1);
|
QCOMPARE(stateSpy.size(), 1);
|
||||||
QCOMPARE(stateSpy.takeFirst().at(0).value<QBluetoothSocket::SocketState>(), QBluetoothSocket::SocketState::ConnectingState);
|
QCOMPARE(stateSpy.takeFirst().at(0).value<QBluetoothSocket::SocketState>(), QBluetoothSocket::SocketState::ConnectingState);
|
||||||
QCOMPARE(socket.state(), QBluetoothSocket::SocketState::ConnectingState);
|
QCOMPARE(socket.state(), QBluetoothSocket::SocketState::ConnectingState);
|
||||||
|
|
||||||
|
@ -273,8 +273,8 @@ void tst_QBluetoothSocket::tst_serviceConnection()
|
||||||
qDebug() << errorSpy.takeFirst().at(0).toInt();
|
qDebug() << errorSpy.takeFirst().at(0).toInt();
|
||||||
QSKIP("Connection error");
|
QSKIP("Connection error");
|
||||||
}
|
}
|
||||||
QCOMPARE(connectedSpy.count(), 1);
|
QCOMPARE(connectedSpy.size(), 1);
|
||||||
QCOMPARE(stateSpy.count(), 1);
|
QCOMPARE(stateSpy.size(), 1);
|
||||||
QCOMPARE(stateSpy.takeFirst().at(0).value<QBluetoothSocket::SocketState>(), QBluetoothSocket::SocketState::ConnectedState);
|
QCOMPARE(stateSpy.takeFirst().at(0).value<QBluetoothSocket::SocketState>(), QBluetoothSocket::SocketState::ConnectedState);
|
||||||
QCOMPARE(socket.state(), QBluetoothSocket::SocketState::ConnectedState);
|
QCOMPARE(socket.state(), QBluetoothSocket::SocketState::ConnectedState);
|
||||||
|
|
||||||
|
@ -314,8 +314,8 @@ void tst_QBluetoothSocket::tst_serviceConnection()
|
||||||
disconnectTime -= 1000;
|
disconnectTime -= 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
QCOMPARE(disconnectedSpy.count(), 1);
|
QCOMPARE(disconnectedSpy.size(), 1);
|
||||||
QCOMPARE(stateSpy.count(), 1);
|
QCOMPARE(stateSpy.size(), 1);
|
||||||
QCOMPARE(stateSpy.takeFirst().at(0).value<QBluetoothSocket::SocketState>(), QBluetoothSocket::SocketState::UnconnectedState);
|
QCOMPARE(stateSpy.takeFirst().at(0).value<QBluetoothSocket::SocketState>(), QBluetoothSocket::SocketState::UnconnectedState);
|
||||||
|
|
||||||
// The remote service needs time to close the connection and resume listening
|
// The remote service needs time to close the connection and resume listening
|
||||||
|
@ -358,7 +358,7 @@ void tst_QBluetoothSocket::tst_clientCommunication()
|
||||||
QCOMPARE(socket.openMode(), QIODevice::NotOpen);
|
QCOMPARE(socket.openMode(), QIODevice::NotOpen);
|
||||||
socket.connectToService(remoteServiceInfo);
|
socket.connectToService(remoteServiceInfo);
|
||||||
|
|
||||||
QCOMPARE(stateSpy.count(), 1);
|
QCOMPARE(stateSpy.size(), 1);
|
||||||
QCOMPARE(qvariant_cast<QBluetoothSocket::SocketState>(stateSpy.takeFirst().at(0)), QBluetoothSocket::SocketState::ConnectingState);
|
QCOMPARE(qvariant_cast<QBluetoothSocket::SocketState>(stateSpy.takeFirst().at(0)), QBluetoothSocket::SocketState::ConnectingState);
|
||||||
QCOMPARE(socket.state(), QBluetoothSocket::SocketState::ConnectingState);
|
QCOMPARE(socket.state(), QBluetoothSocket::SocketState::ConnectingState);
|
||||||
|
|
||||||
|
@ -374,8 +374,8 @@ void tst_QBluetoothSocket::tst_clientCommunication()
|
||||||
QCOMPARE(socket.isReadable(), true);
|
QCOMPARE(socket.isReadable(), true);
|
||||||
QCOMPARE(socket.isOpen(), true);
|
QCOMPARE(socket.isOpen(), true);
|
||||||
|
|
||||||
QCOMPARE(connectedSpy.count(), 1);
|
QCOMPARE(connectedSpy.size(), 1);
|
||||||
QCOMPARE(stateSpy.count(), 1);
|
QCOMPARE(stateSpy.size(), 1);
|
||||||
QCOMPARE(qvariant_cast<QBluetoothSocket::SocketState>(stateSpy.takeFirst().at(0)), QBluetoothSocket::SocketState::ConnectedState);
|
QCOMPARE(qvariant_cast<QBluetoothSocket::SocketState>(stateSpy.takeFirst().at(0)), QBluetoothSocket::SocketState::ConnectedState);
|
||||||
QCOMPARE(socket.state(), QBluetoothSocket::SocketState::ConnectedState);
|
QCOMPARE(socket.state(), QBluetoothSocket::SocketState::ConnectedState);
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ void tst_QBluetoothSocket::tst_clientCommunication()
|
||||||
readWriteTime -= 1000;
|
readWriteTime -= 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
QCOMPARE(bytesWrittenSpy.count(), 1);
|
QCOMPARE(bytesWrittenSpy.size(), 1);
|
||||||
QCOMPARE(bytesWrittenSpy.at(0).at(0).toLongLong(), qint64(line.length()));
|
QCOMPARE(bytesWrittenSpy.at(0).at(0).toLongLong(), qint64(line.length()));
|
||||||
|
|
||||||
readWriteTime = MaxReadWriteTime;
|
readWriteTime = MaxReadWriteTime;
|
||||||
|
@ -415,7 +415,7 @@ void tst_QBluetoothSocket::tst_clientCommunication()
|
||||||
readWriteTime -= 1000;
|
readWriteTime -= 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
QCOMPARE(readyReadSpy.count(), 1);
|
QCOMPARE(readyReadSpy.size(), 1);
|
||||||
|
|
||||||
if (socket.openMode() & QIODevice::Unbuffered)
|
if (socket.openMode() & QIODevice::Unbuffered)
|
||||||
QVERIFY(socket.bytesAvailable() <= qint64(line.length()));
|
QVERIFY(socket.bytesAvailable() <= qint64(line.length()));
|
||||||
|
@ -455,7 +455,7 @@ void tst_QBluetoothSocket::tst_clientCommunication()
|
||||||
readWriteTime -= 1000;
|
readWriteTime -= 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
QCOMPARE(bytesWrittenSpy.count(), 1);
|
QCOMPARE(bytesWrittenSpy.size(), 1);
|
||||||
QCOMPARE(bytesWrittenSpy.at(0).at(0).toLongLong(), qint64(joined.length()));
|
QCOMPARE(bytesWrittenSpy.at(0).at(0).toLongLong(), qint64(joined.length()));
|
||||||
QVERIFY(!readyReadSpy.isEmpty());
|
QVERIFY(!readyReadSpy.isEmpty());
|
||||||
|
|
||||||
|
@ -487,8 +487,8 @@ void tst_QBluetoothSocket::tst_clientCommunication()
|
||||||
disconnectTime -= 1000;
|
disconnectTime -= 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
QCOMPARE(disconnectedSpy.count(), 1);
|
QCOMPARE(disconnectedSpy.size(), 1);
|
||||||
QCOMPARE(stateSpy.count(), 2);
|
QCOMPARE(stateSpy.size(), 2);
|
||||||
QCOMPARE(qvariant_cast<QBluetoothSocket::SocketState>(stateSpy.takeFirst().at(0)), QBluetoothSocket::SocketState::ClosingState);
|
QCOMPARE(qvariant_cast<QBluetoothSocket::SocketState>(stateSpy.takeFirst().at(0)), QBluetoothSocket::SocketState::ClosingState);
|
||||||
QCOMPARE(qvariant_cast<QBluetoothSocket::SocketState>(stateSpy.takeFirst().at(0)), QBluetoothSocket::SocketState::UnconnectedState);
|
QCOMPARE(qvariant_cast<QBluetoothSocket::SocketState>(stateSpy.takeFirst().at(0)), QBluetoothSocket::SocketState::UnconnectedState);
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ void tst_QBluetoothSocket::tst_error()
|
||||||
{
|
{
|
||||||
QBluetoothSocket socket;
|
QBluetoothSocket socket;
|
||||||
QSignalSpy errorSpy(&socket, SIGNAL(errorOccurred(QBluetoothSocket::SocketError)));
|
QSignalSpy errorSpy(&socket, SIGNAL(errorOccurred(QBluetoothSocket::SocketError)));
|
||||||
QCOMPARE(errorSpy.count(), 0);
|
QCOMPARE(errorSpy.size(), 0);
|
||||||
const QBluetoothSocket::SocketError e = socket.error();
|
const QBluetoothSocket::SocketError e = socket.error();
|
||||||
|
|
||||||
QVERIFY(e == QBluetoothSocket::SocketError::NoSocketError);
|
QVERIFY(e == QBluetoothSocket::SocketError::NoSocketError);
|
||||||
|
|
|
@ -134,8 +134,8 @@ void tst_QLowEnergyCharacteristic::initTestCase()
|
||||||
QSignalSpy discoveryFinishedSpy(controller, SIGNAL(discoveryFinished()));
|
QSignalSpy discoveryFinishedSpy(controller, SIGNAL(discoveryFinished()));
|
||||||
QSignalSpy stateSpy(controller, SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
QSignalSpy stateSpy(controller, SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
||||||
controller->discoverServices();
|
controller->discoverServices();
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000);
|
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.size() == 1, 10000);
|
||||||
QCOMPARE(stateSpy.count(), 2);
|
QCOMPARE(stateSpy.size(), 2);
|
||||||
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
QLowEnergyController::DiscoveringState);
|
QLowEnergyController::DiscoveringState);
|
||||||
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
|
@ -199,7 +199,7 @@ void tst_QLowEnergyCharacteristic::tst_constructionDefault()
|
||||||
QCOMPARE(characteristic.value(), QByteArray());
|
QCOMPARE(characteristic.value(), QByteArray());
|
||||||
QVERIFY(characteristic.uuid().isNull());
|
QVERIFY(characteristic.uuid().isNull());
|
||||||
QCOMPARE(characteristic.name(), QString());
|
QCOMPARE(characteristic.name(), QString());
|
||||||
QCOMPARE(characteristic.descriptors().count(), 0);
|
QCOMPARE(characteristic.descriptors().size(), 0);
|
||||||
QCOMPARE(characteristic.descriptor(QBluetoothUuid()),
|
QCOMPARE(characteristic.descriptor(QBluetoothUuid()),
|
||||||
QLowEnergyDescriptor());
|
QLowEnergyDescriptor());
|
||||||
QCOMPARE(characteristic.descriptor(QBluetoothUuid(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration)),
|
QCOMPARE(characteristic.descriptor(QBluetoothUuid(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration)),
|
||||||
|
@ -213,7 +213,7 @@ void tst_QLowEnergyCharacteristic::tst_constructionDefault()
|
||||||
QCOMPARE(copyConstructed.value(), QByteArray());
|
QCOMPARE(copyConstructed.value(), QByteArray());
|
||||||
QVERIFY(copyConstructed.uuid().isNull());
|
QVERIFY(copyConstructed.uuid().isNull());
|
||||||
QCOMPARE(copyConstructed.name(), QString());
|
QCOMPARE(copyConstructed.name(), QString());
|
||||||
QCOMPARE(copyConstructed.descriptors().count(), 0);
|
QCOMPARE(copyConstructed.descriptors().size(), 0);
|
||||||
QCOMPARE(copyConstructed.properties(), QLowEnergyCharacteristic::Unknown);
|
QCOMPARE(copyConstructed.properties(), QLowEnergyCharacteristic::Unknown);
|
||||||
|
|
||||||
QVERIFY(copyConstructed == characteristic);
|
QVERIFY(copyConstructed == characteristic);
|
||||||
|
@ -233,7 +233,7 @@ void tst_QLowEnergyCharacteristic::tst_constructionDefault()
|
||||||
QCOMPARE(assigned.value(), QByteArray());
|
QCOMPARE(assigned.value(), QByteArray());
|
||||||
QVERIFY(assigned.uuid().isNull());
|
QVERIFY(assigned.uuid().isNull());
|
||||||
QCOMPARE(assigned.name(), QString());
|
QCOMPARE(assigned.name(), QString());
|
||||||
QCOMPARE(assigned.descriptors().count(), 0);
|
QCOMPARE(assigned.descriptors().size(), 0);
|
||||||
QCOMPARE(assigned.properties(), QLowEnergyCharacteristic::Unknown);
|
QCOMPARE(assigned.properties(), QLowEnergyCharacteristic::Unknown);
|
||||||
|
|
||||||
QVERIFY(assigned == characteristic);
|
QVERIFY(assigned == characteristic);
|
||||||
|
@ -252,7 +252,7 @@ void tst_QLowEnergyCharacteristic::tst_assignCompare()
|
||||||
QCOMPARE(target.value(), QByteArray());
|
QCOMPARE(target.value(), QByteArray());
|
||||||
QVERIFY(target.uuid().isNull());
|
QVERIFY(target.uuid().isNull());
|
||||||
QCOMPARE(target.name(), QString());
|
QCOMPARE(target.name(), QString());
|
||||||
QCOMPARE(target.descriptors().count(), 0);
|
QCOMPARE(target.descriptors().size(), 0);
|
||||||
QCOMPARE(target.properties(), QLowEnergyCharacteristic::Unknown);
|
QCOMPARE(target.properties(), QLowEnergyCharacteristic::Unknown);
|
||||||
|
|
||||||
int indexWithDescriptor = -1;
|
int indexWithDescriptor = -1;
|
||||||
|
@ -297,8 +297,8 @@ void tst_QLowEnergyCharacteristic::tst_assignCompare()
|
||||||
QCOMPARE(target.uuid(), chars[indexWithDescriptor].uuid());
|
QCOMPARE(target.uuid(), chars[indexWithDescriptor].uuid());
|
||||||
QCOMPARE(target.value(), chars[indexWithDescriptor].value());
|
QCOMPARE(target.value(), chars[indexWithDescriptor].value());
|
||||||
QCOMPARE(target.properties(), chars[indexWithDescriptor].properties());
|
QCOMPARE(target.properties(), chars[indexWithDescriptor].properties());
|
||||||
QCOMPARE(target.descriptors().count(),
|
QCOMPARE(target.descriptors().size(),
|
||||||
chars[indexWithDescriptor].descriptors().count());
|
chars[indexWithDescriptor].descriptors().size());
|
||||||
for (int i = 0; i < target.descriptors().count(); i++) {
|
for (int i = 0; i < target.descriptors().count(); i++) {
|
||||||
const QLowEnergyDescriptor ref = chars[indexWithDescriptor].descriptors()[i];
|
const QLowEnergyDescriptor ref = chars[indexWithDescriptor].descriptors()[i];
|
||||||
QCOMPARE(target.descriptors()[i].name(), ref.name());
|
QCOMPARE(target.descriptors()[i].name(), ref.name());
|
||||||
|
@ -318,8 +318,8 @@ void tst_QLowEnergyCharacteristic::tst_assignCompare()
|
||||||
QCOMPARE(copyConstructed.uuid(), chars[indexWithDescriptor].uuid());
|
QCOMPARE(copyConstructed.uuid(), chars[indexWithDescriptor].uuid());
|
||||||
QCOMPARE(copyConstructed.value(), chars[indexWithDescriptor].value());
|
QCOMPARE(copyConstructed.value(), chars[indexWithDescriptor].value());
|
||||||
QCOMPARE(copyConstructed.properties(), chars[indexWithDescriptor].properties());
|
QCOMPARE(copyConstructed.properties(), chars[indexWithDescriptor].properties());
|
||||||
QCOMPARE(copyConstructed.descriptors().count(),
|
QCOMPARE(copyConstructed.descriptors().size(),
|
||||||
chars[indexWithDescriptor].descriptors().count());
|
chars[indexWithDescriptor].descriptors().size());
|
||||||
|
|
||||||
QVERIFY(copyConstructed == target);
|
QVERIFY(copyConstructed == target);
|
||||||
QVERIFY(target == copyConstructed);
|
QVERIFY(target == copyConstructed);
|
||||||
|
@ -333,7 +333,7 @@ void tst_QLowEnergyCharacteristic::tst_assignCompare()
|
||||||
QCOMPARE(target.value(), QByteArray());
|
QCOMPARE(target.value(), QByteArray());
|
||||||
QVERIFY(target.uuid().isNull());
|
QVERIFY(target.uuid().isNull());
|
||||||
QCOMPARE(target.name(), QString());
|
QCOMPARE(target.name(), QString());
|
||||||
QCOMPARE(target.descriptors().count(), 0);
|
QCOMPARE(target.descriptors().size(), 0);
|
||||||
QCOMPARE(target.properties(), QLowEnergyCharacteristic::Unknown);
|
QCOMPARE(target.properties(), QLowEnergyCharacteristic::Unknown);
|
||||||
|
|
||||||
QVERIFY(invalid == target);
|
QVERIFY(invalid == target);
|
||||||
|
@ -346,7 +346,7 @@ void tst_QLowEnergyCharacteristic::tst_assignCompare()
|
||||||
QVERIFY(chars[indexWithDescriptor] != target);
|
QVERIFY(chars[indexWithDescriptor] != target);
|
||||||
QVERIFY(target != chars[indexWithDescriptor]);
|
QVERIFY(target != chars[indexWithDescriptor]);
|
||||||
|
|
||||||
if (chars.count() >= 2) {
|
if (chars.size() >= 2) {
|
||||||
// at least two characteristics
|
// at least two characteristics
|
||||||
QVERIFY(!(chars[0] == chars[1]));
|
QVERIFY(!(chars[0] == chars[1]));
|
||||||
QVERIFY(!(chars[1] == chars[0]));
|
QVERIFY(!(chars[1] == chars[0]));
|
||||||
|
|
|
@ -286,7 +286,7 @@ void TestQLowEnergyControllerGattServer::advertisedData()
|
||||||
// name is seen on the scanning machine.
|
// name is seen on the scanning machine.
|
||||||
// QCOMPARE(m_serverInfo.name(), QString("Qt GATT server"));
|
// QCOMPARE(m_serverInfo.name(), QString("Qt GATT server"));
|
||||||
|
|
||||||
QVERIFY(m_serverInfo.serviceUuids().count() >= 3);
|
QVERIFY(m_serverInfo.serviceUuids().size() >= 3);
|
||||||
QVERIFY(m_serverInfo.serviceUuids().contains(QBluetoothUuid::ServiceClassUuid::GenericAccess));
|
QVERIFY(m_serverInfo.serviceUuids().contains(QBluetoothUuid::ServiceClassUuid::GenericAccess));
|
||||||
QVERIFY(m_serverInfo.serviceUuids().contains(QBluetoothUuid::ServiceClassUuid::RunningSpeedAndCadence));
|
QVERIFY(m_serverInfo.serviceUuids().contains(QBluetoothUuid::ServiceClassUuid::RunningSpeedAndCadence));
|
||||||
QVERIFY(m_serverInfo.serviceUuids().contains(QBluetoothUuid(quint16(0x2000))));
|
QVERIFY(m_serverInfo.serviceUuids().contains(QBluetoothUuid(quint16(0x2000))));
|
||||||
|
@ -306,7 +306,7 @@ void TestQLowEnergyControllerGattServer::serverCommunication()
|
||||||
spy.reset(new QSignalSpy(m_leController.data(), &QLowEnergyController::discoveryFinished));
|
spy.reset(new QSignalSpy(m_leController.data(), &QLowEnergyController::discoveryFinished));
|
||||||
QVERIFY(spy->wait(30000));
|
QVERIFY(spy->wait(30000));
|
||||||
const QList<QBluetoothUuid> serviceUuids = m_leController->services();
|
const QList<QBluetoothUuid> serviceUuids = m_leController->services();
|
||||||
QCOMPARE(serviceUuids.count(), 4);
|
QCOMPARE(serviceUuids.size(), 4);
|
||||||
QVERIFY(serviceUuids.contains(QBluetoothUuid::ServiceClassUuid::GenericAccess));
|
QVERIFY(serviceUuids.contains(QBluetoothUuid::ServiceClassUuid::GenericAccess));
|
||||||
QVERIFY(serviceUuids.contains(QBluetoothUuid::ServiceClassUuid::RunningSpeedAndCadence));
|
QVERIFY(serviceUuids.contains(QBluetoothUuid::ServiceClassUuid::RunningSpeedAndCadence));
|
||||||
QVERIFY(serviceUuids.contains(QBluetoothUuid(quint16(0x2000))));
|
QVERIFY(serviceUuids.contains(QBluetoothUuid(quint16(0x2000))));
|
||||||
|
@ -320,21 +320,21 @@ void TestQLowEnergyControllerGattServer::serverCommunication()
|
||||||
spy.reset(new QSignalSpy(genericAccessService.data(), &QLowEnergyService::stateChanged));
|
spy.reset(new QSignalSpy(genericAccessService.data(), &QLowEnergyService::stateChanged));
|
||||||
QVERIFY(spy->wait(3000));
|
QVERIFY(spy->wait(3000));
|
||||||
}
|
}
|
||||||
QCOMPARE(genericAccessService->includedServices().count(), 1);
|
QCOMPARE(genericAccessService->includedServices().size(), 1);
|
||||||
QCOMPARE(genericAccessService->includedServices().first(),
|
QCOMPARE(genericAccessService->includedServices().first(),
|
||||||
QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::RunningSpeedAndCadence));
|
QBluetoothUuid(QBluetoothUuid::ServiceClassUuid::RunningSpeedAndCadence));
|
||||||
QCOMPARE(genericAccessService->characteristics().count(), 2);
|
QCOMPARE(genericAccessService->characteristics().size(), 2);
|
||||||
const QLowEnergyCharacteristic deviceNameChar
|
const QLowEnergyCharacteristic deviceNameChar
|
||||||
= genericAccessService->characteristic(QBluetoothUuid::CharacteristicType::DeviceName);
|
= genericAccessService->characteristic(QBluetoothUuid::CharacteristicType::DeviceName);
|
||||||
QVERIFY(deviceNameChar.isValid());
|
QVERIFY(deviceNameChar.isValid());
|
||||||
QCOMPARE(deviceNameChar.descriptors().count(), 0);
|
QCOMPARE(deviceNameChar.descriptors().size(), 0);
|
||||||
QCOMPARE(deviceNameChar.properties(),
|
QCOMPARE(deviceNameChar.properties(),
|
||||||
QLowEnergyCharacteristic::Read | QLowEnergyCharacteristic::Write);
|
QLowEnergyCharacteristic::Read | QLowEnergyCharacteristic::Write);
|
||||||
QCOMPARE(deviceNameChar.value().constData(), "Qt GATT server");
|
QCOMPARE(deviceNameChar.value().constData(), "Qt GATT server");
|
||||||
const QLowEnergyCharacteristic appearanceChar
|
const QLowEnergyCharacteristic appearanceChar
|
||||||
= genericAccessService->characteristic(QBluetoothUuid::CharacteristicType::Appearance);
|
= genericAccessService->characteristic(QBluetoothUuid::CharacteristicType::Appearance);
|
||||||
QVERIFY(appearanceChar.isValid());
|
QVERIFY(appearanceChar.isValid());
|
||||||
QCOMPARE(appearanceChar.descriptors().count(), 0);
|
QCOMPARE(appearanceChar.descriptors().size(), 0);
|
||||||
QCOMPARE(appearanceChar.properties(), QLowEnergyCharacteristic::Read);
|
QCOMPARE(appearanceChar.properties(), QLowEnergyCharacteristic::Read);
|
||||||
auto value = qFromLittleEndian<quint16>(reinterpret_cast<const uchar *>(
|
auto value = qFromLittleEndian<quint16>(reinterpret_cast<const uchar *>(
|
||||||
appearanceChar.value().constData()));
|
appearanceChar.value().constData()));
|
||||||
|
@ -348,12 +348,12 @@ void TestQLowEnergyControllerGattServer::serverCommunication()
|
||||||
spy.reset(new QSignalSpy(runningSpeedService.data(), &QLowEnergyService::stateChanged));
|
spy.reset(new QSignalSpy(runningSpeedService.data(), &QLowEnergyService::stateChanged));
|
||||||
QVERIFY(spy->wait(3000));
|
QVERIFY(spy->wait(3000));
|
||||||
}
|
}
|
||||||
QCOMPARE(runningSpeedService->includedServices().count(), 0);
|
QCOMPARE(runningSpeedService->includedServices().size(), 0);
|
||||||
QCOMPARE(runningSpeedService->characteristics().count(), 2);
|
QCOMPARE(runningSpeedService->characteristics().size(), 2);
|
||||||
QLowEnergyCharacteristic measurementChar
|
QLowEnergyCharacteristic measurementChar
|
||||||
= runningSpeedService->characteristic(QBluetoothUuid::CharacteristicType::RSCMeasurement);
|
= runningSpeedService->characteristic(QBluetoothUuid::CharacteristicType::RSCMeasurement);
|
||||||
QVERIFY(measurementChar.isValid());
|
QVERIFY(measurementChar.isValid());
|
||||||
QCOMPARE(measurementChar.descriptors().count(), 1);
|
QCOMPARE(measurementChar.descriptors().size(), 1);
|
||||||
const QLowEnergyDescriptor clientConfigDesc
|
const QLowEnergyDescriptor clientConfigDesc
|
||||||
= measurementChar.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration);
|
= measurementChar.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration);
|
||||||
QVERIFY(clientConfigDesc.isValid());
|
QVERIFY(clientConfigDesc.isValid());
|
||||||
|
@ -363,7 +363,7 @@ void TestQLowEnergyControllerGattServer::serverCommunication()
|
||||||
QLowEnergyCharacteristic featureChar
|
QLowEnergyCharacteristic featureChar
|
||||||
= runningSpeedService->characteristic(QBluetoothUuid::CharacteristicType::RSCFeature);
|
= runningSpeedService->characteristic(QBluetoothUuid::CharacteristicType::RSCFeature);
|
||||||
QVERIFY(featureChar.isValid());
|
QVERIFY(featureChar.isValid());
|
||||||
QCOMPARE(featureChar.descriptors().count(), 0);
|
QCOMPARE(featureChar.descriptors().size(), 0);
|
||||||
QCOMPARE(featureChar.properties(), QLowEnergyCharacteristic::Read);
|
QCOMPARE(featureChar.properties(), QLowEnergyCharacteristic::Read);
|
||||||
value = qFromLittleEndian<quint16>(reinterpret_cast<const uchar *>(
|
value = qFromLittleEndian<quint16>(reinterpret_cast<const uchar *>(
|
||||||
featureChar.value().constData()));
|
featureChar.value().constData()));
|
||||||
|
@ -381,12 +381,12 @@ void TestQLowEnergyControllerGattServer::serverCommunication()
|
||||||
QVERIFY(spy->wait(5000));
|
QVERIFY(spy->wait(5000));
|
||||||
}
|
}
|
||||||
QCOMPARE(customService128->serviceUuid(), serviceUuid128);
|
QCOMPARE(customService128->serviceUuid(), serviceUuid128);
|
||||||
QCOMPARE(customService128->includedServices().count(), 0);
|
QCOMPARE(customService128->includedServices().size(), 0);
|
||||||
QCOMPARE(customService128->characteristics().count(), 1);
|
QCOMPARE(customService128->characteristics().size(), 1);
|
||||||
QLowEnergyCharacteristic customChar128
|
QLowEnergyCharacteristic customChar128
|
||||||
= customService128->characteristic(charUuid128);
|
= customService128->characteristic(charUuid128);
|
||||||
QVERIFY(customChar128.isValid());
|
QVERIFY(customChar128.isValid());
|
||||||
QCOMPARE(customChar128.descriptors().count(), 0);
|
QCOMPARE(customChar128.descriptors().size(), 0);
|
||||||
QCOMPARE(customChar128.value(), QByteArray(15, 'a'));
|
QCOMPARE(customChar128.value(), QByteArray(15, 'a'));
|
||||||
|
|
||||||
QScopedPointer<QLowEnergyService> customService(
|
QScopedPointer<QLowEnergyService> customService(
|
||||||
|
@ -397,18 +397,18 @@ void TestQLowEnergyControllerGattServer::serverCommunication()
|
||||||
spy.reset(new QSignalSpy(customService.data(), &QLowEnergyService::stateChanged));
|
spy.reset(new QSignalSpy(customService.data(), &QLowEnergyService::stateChanged));
|
||||||
QVERIFY(spy->wait(5000));
|
QVERIFY(spy->wait(5000));
|
||||||
}
|
}
|
||||||
QCOMPARE(customService->includedServices().count(), 0);
|
QCOMPARE(customService->includedServices().size(), 0);
|
||||||
QCOMPARE(customService->characteristics().count(), 5);
|
QCOMPARE(customService->characteristics().size(), 5);
|
||||||
QLowEnergyCharacteristic customChar
|
QLowEnergyCharacteristic customChar
|
||||||
= customService->characteristic(QBluetoothUuid(quint16(0x5000)));
|
= customService->characteristic(QBluetoothUuid(quint16(0x5000)));
|
||||||
QVERIFY(customChar.isValid());
|
QVERIFY(customChar.isValid());
|
||||||
QCOMPARE(customChar.descriptors().count(), 0);
|
QCOMPARE(customChar.descriptors().size(), 0);
|
||||||
QCOMPARE(customChar.value(), QByteArray(1024, 'x'));
|
QCOMPARE(customChar.value(), QByteArray(1024, 'x'));
|
||||||
|
|
||||||
QLowEnergyCharacteristic customChar2
|
QLowEnergyCharacteristic customChar2
|
||||||
= customService->characteristic(QBluetoothUuid(quint16(0x5001)));
|
= customService->characteristic(QBluetoothUuid(quint16(0x5001)));
|
||||||
QVERIFY(customChar2.isValid());
|
QVERIFY(customChar2.isValid());
|
||||||
QCOMPARE(customChar2.descriptors().count(), 0);
|
QCOMPARE(customChar2.descriptors().size(), 0);
|
||||||
QCOMPARE(customChar2.value(), QByteArray()); // Was not readable due to authorization requirement.
|
QCOMPARE(customChar2.value(), QByteArray()); // Was not readable due to authorization requirement.
|
||||||
|
|
||||||
QLowEnergyCharacteristic customChar3
|
QLowEnergyCharacteristic customChar3
|
||||||
|
@ -416,7 +416,7 @@ void TestQLowEnergyControllerGattServer::serverCommunication()
|
||||||
QVERIFY(customChar3.isValid());
|
QVERIFY(customChar3.isValid());
|
||||||
QCOMPARE(customChar3.properties(),
|
QCOMPARE(customChar3.properties(),
|
||||||
QLowEnergyCharacteristic::Read | QLowEnergyCharacteristic::Indicate);
|
QLowEnergyCharacteristic::Read | QLowEnergyCharacteristic::Indicate);
|
||||||
QCOMPARE(customChar3.descriptors().count(), 1);
|
QCOMPARE(customChar3.descriptors().size(), 1);
|
||||||
QLowEnergyDescriptor cc3ClientConfig
|
QLowEnergyDescriptor cc3ClientConfig
|
||||||
= customChar3.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration);
|
= customChar3.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration);
|
||||||
QVERIFY(cc3ClientConfig.isValid());
|
QVERIFY(cc3ClientConfig.isValid());
|
||||||
|
@ -426,7 +426,7 @@ void TestQLowEnergyControllerGattServer::serverCommunication()
|
||||||
QVERIFY(customChar4.isValid());
|
QVERIFY(customChar4.isValid());
|
||||||
QCOMPARE(customChar4.properties(),
|
QCOMPARE(customChar4.properties(),
|
||||||
QLowEnergyCharacteristic::Read | QLowEnergyCharacteristic::Notify);
|
QLowEnergyCharacteristic::Read | QLowEnergyCharacteristic::Notify);
|
||||||
QCOMPARE(customChar4.descriptors().count(), 1);
|
QCOMPARE(customChar4.descriptors().size(), 1);
|
||||||
QLowEnergyDescriptor cc4ClientConfig
|
QLowEnergyDescriptor cc4ClientConfig
|
||||||
= customChar4.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration);
|
= customChar4.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration);
|
||||||
QVERIFY(cc4ClientConfig.isValid());
|
QVERIFY(cc4ClientConfig.isValid());
|
||||||
|
@ -436,7 +436,7 @@ void TestQLowEnergyControllerGattServer::serverCommunication()
|
||||||
QVERIFY(customChar5.isValid());
|
QVERIFY(customChar5.isValid());
|
||||||
QCOMPARE(customChar5.properties(),
|
QCOMPARE(customChar5.properties(),
|
||||||
QLowEnergyCharacteristic::Read | QLowEnergyCharacteristic::WriteSigned);
|
QLowEnergyCharacteristic::Read | QLowEnergyCharacteristic::WriteSigned);
|
||||||
QCOMPARE(customChar5.descriptors().count(), 0);
|
QCOMPARE(customChar5.descriptors().size(), 0);
|
||||||
QCOMPARE(customChar5.value(), QByteArray("initial"));
|
QCOMPARE(customChar5.value(), QByteArray("initial"));
|
||||||
|
|
||||||
customService->writeCharacteristic(customChar, "whatever");
|
customService->writeCharacteristic(customChar, "whatever");
|
||||||
|
@ -482,7 +482,7 @@ void TestQLowEnergyControllerGattServer::serverCommunication()
|
||||||
|
|
||||||
spy.reset(new QSignalSpy(customService.data(), &QLowEnergyService::characteristicChanged));
|
spy.reset(new QSignalSpy(customService.data(), &QLowEnergyService::characteristicChanged));
|
||||||
QVERIFY(spy->wait(3000));
|
QVERIFY(spy->wait(3000));
|
||||||
if (spy->count() == 1)
|
if (spy->size() == 1)
|
||||||
QVERIFY(spy->wait(3000));
|
QVERIFY(spy->wait(3000));
|
||||||
QCOMPARE(customChar3.value().constData(), "indicated");
|
QCOMPARE(customChar3.value().constData(), "indicated");
|
||||||
QCOMPARE(customChar4.value().constData(), "notified");
|
QCOMPARE(customChar4.value().constData(), "notified");
|
||||||
|
@ -616,9 +616,9 @@ void TestQLowEnergyControllerGattServer::serviceData()
|
||||||
| AttAccessConstraint::AttAuthorizationRequired);
|
| AttAccessConstraint::AttAuthorizationRequired);
|
||||||
|
|
||||||
charData.addDescriptor(descData);
|
charData.addDescriptor(descData);
|
||||||
QCOMPARE(charData.descriptors().count(), 1);
|
QCOMPARE(charData.descriptors().size(), 1);
|
||||||
charData.setDescriptors(QList<QLowEnergyDescriptorData>());
|
charData.setDescriptors(QList<QLowEnergyDescriptorData>());
|
||||||
QCOMPARE(charData.descriptors().count(), 0);
|
QCOMPARE(charData.descriptors().size(), 0);
|
||||||
charData.setDescriptors(QList<QLowEnergyDescriptorData>() << descData << descData2);
|
charData.setDescriptors(QList<QLowEnergyDescriptorData>() << descData << descData2);
|
||||||
QLowEnergyDescriptorData descData3(QBluetoothUuid::DescriptorType::ExternalReportReference, "someval");
|
QLowEnergyDescriptorData descData3(QBluetoothUuid::DescriptorType::ExternalReportReference, "someval");
|
||||||
charData.addDescriptor(descData3);
|
charData.addDescriptor(descData3);
|
||||||
|
@ -638,9 +638,9 @@ void TestQLowEnergyControllerGattServer::serviceData()
|
||||||
QCOMPARE(secondaryData.type(), QLowEnergyServiceData::ServiceTypeSecondary);
|
QCOMPARE(secondaryData.type(), QLowEnergyServiceData::ServiceTypeSecondary);
|
||||||
|
|
||||||
secondaryData.addCharacteristic(charData);
|
secondaryData.addCharacteristic(charData);
|
||||||
QCOMPARE(secondaryData.characteristics().count(), 1);
|
QCOMPARE(secondaryData.characteristics().size(), 1);
|
||||||
secondaryData.setCharacteristics(QList<QLowEnergyCharacteristicData>());
|
secondaryData.setCharacteristics(QList<QLowEnergyCharacteristicData>());
|
||||||
QCOMPARE(secondaryData.characteristics().count(), 0);
|
QCOMPARE(secondaryData.characteristics().size(), 0);
|
||||||
secondaryData.setCharacteristics(QList<QLowEnergyCharacteristicData>()
|
secondaryData.setCharacteristics(QList<QLowEnergyCharacteristicData>()
|
||||||
<< charData << QLowEnergyCharacteristicData());
|
<< charData << QLowEnergyCharacteristicData());
|
||||||
QCOMPARE(secondaryData.characteristics(), QList<QLowEnergyCharacteristicData>() << charData);
|
QCOMPARE(secondaryData.characteristics(), QList<QLowEnergyCharacteristicData>() << charData);
|
||||||
|
@ -668,10 +668,10 @@ void TestQLowEnergyControllerGattServer::serviceData()
|
||||||
QVERIFY(!secondaryService.isNull());
|
QVERIFY(!secondaryService.isNull());
|
||||||
QCOMPARE(secondaryService->serviceUuid(), secondaryData.uuid());
|
QCOMPARE(secondaryService->serviceUuid(), secondaryData.uuid());
|
||||||
const QList<QLowEnergyCharacteristic> characteristics = secondaryService->characteristics();
|
const QList<QLowEnergyCharacteristic> characteristics = secondaryService->characteristics();
|
||||||
QCOMPARE(characteristics.count(), 1);
|
QCOMPARE(characteristics.size(), 1);
|
||||||
QCOMPARE(characteristics.first().uuid(), charData.uuid());
|
QCOMPARE(characteristics.first().uuid(), charData.uuid());
|
||||||
const QList<QLowEnergyDescriptor> descriptors = characteristics.first().descriptors();
|
const QList<QLowEnergyDescriptor> descriptors = characteristics.first().descriptors();
|
||||||
QCOMPARE(descriptors.count(), 3);
|
QCOMPARE(descriptors.size(), 3);
|
||||||
const auto inUuids = QSet<QBluetoothUuid>() << descData.uuid() << descData2.uuid()
|
const auto inUuids = QSet<QBluetoothUuid>() << descData.uuid() << descData2.uuid()
|
||||||
<< descData3.uuid();
|
<< descData3.uuid();
|
||||||
QSet<QBluetoothUuid> outUuids;
|
QSet<QBluetoothUuid> outUuids;
|
||||||
|
@ -684,9 +684,9 @@ void TestQLowEnergyControllerGattServer::serviceData()
|
||||||
primaryData.addIncludedService(secondaryService.data());
|
primaryData.addIncludedService(secondaryService.data());
|
||||||
const QScopedPointer<QLowEnergyService> primaryService(controller->addService(primaryData));
|
const QScopedPointer<QLowEnergyService> primaryService(controller->addService(primaryData));
|
||||||
QVERIFY(!primaryService.isNull());
|
QVERIFY(!primaryService.isNull());
|
||||||
QCOMPARE(primaryService->characteristics().count(), 0);
|
QCOMPARE(primaryService->characteristics().size(), 0);
|
||||||
const QList<QBluetoothUuid> includedServices = primaryService->includedServices();
|
const QList<QBluetoothUuid> includedServices = primaryService->includedServices();
|
||||||
QCOMPARE(includedServices.count(), 1);
|
QCOMPARE(includedServices.size(), 1);
|
||||||
QCOMPARE(includedServices.first(), secondaryService->serviceUuid());
|
QCOMPARE(includedServices.first(), secondaryService->serviceUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,8 +275,8 @@ void tst_QLowEnergyController::tst_connect()
|
||||||
QCOMPARE(control->state(), QLowEnergyController::UnconnectedState);
|
QCOMPARE(control->state(), QLowEnergyController::UnconnectedState);
|
||||||
QCOMPARE(control->error(), QLowEnergyController::NoError);
|
QCOMPARE(control->error(), QLowEnergyController::NoError);
|
||||||
QVERIFY(control->errorString().isEmpty());
|
QVERIFY(control->errorString().isEmpty());
|
||||||
QCOMPARE(disconnectedSpy.count(), 0);
|
QCOMPARE(disconnectedSpy.size(), 0);
|
||||||
QCOMPARE(connectedSpy.count(), 0);
|
QCOMPARE(connectedSpy.size(), 0);
|
||||||
QVERIFY(control->services().isEmpty());
|
QVERIFY(control->services().isEmpty());
|
||||||
|
|
||||||
bool wasError = false;
|
bool wasError = false;
|
||||||
|
@ -284,15 +284,15 @@ void tst_QLowEnergyController::tst_connect()
|
||||||
QTRY_IMPL(control->state() != QLowEnergyController::ConnectingState,
|
QTRY_IMPL(control->state() != QLowEnergyController::ConnectingState,
|
||||||
10000)
|
10000)
|
||||||
|
|
||||||
QCOMPARE(disconnectedSpy.count(), 0);
|
QCOMPARE(disconnectedSpy.size(), 0);
|
||||||
if (control->error() != QLowEnergyController::NoError) {
|
if (control->error() != QLowEnergyController::NoError) {
|
||||||
//error during connect
|
//error during connect
|
||||||
QCOMPARE(connectedSpy.count(), 0);
|
QCOMPARE(connectedSpy.size(), 0);
|
||||||
QCOMPARE(control->state(), QLowEnergyController::UnconnectedState);
|
QCOMPARE(control->state(), QLowEnergyController::UnconnectedState);
|
||||||
wasError = true;
|
wasError = true;
|
||||||
} else if (control->state() == QLowEnergyController::ConnectingState) {
|
} else if (control->state() == QLowEnergyController::ConnectingState) {
|
||||||
//timeout
|
//timeout
|
||||||
QCOMPARE(connectedSpy.count(), 0);
|
QCOMPARE(connectedSpy.size(), 0);
|
||||||
QVERIFY(control->errorString().isEmpty());
|
QVERIFY(control->errorString().isEmpty());
|
||||||
QCOMPARE(control->error(), QLowEnergyController::NoError);
|
QCOMPARE(control->error(), QLowEnergyController::NoError);
|
||||||
QVERIFY(control->services().isEmpty());
|
QVERIFY(control->services().isEmpty());
|
||||||
|
@ -300,7 +300,7 @@ void tst_QLowEnergyController::tst_connect()
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
QCOMPARE(control->state(), QLowEnergyController::ConnectedState);
|
QCOMPARE(control->state(), QLowEnergyController::ConnectedState);
|
||||||
QCOMPARE(connectedSpy.count(), 1);
|
QCOMPARE(connectedSpy.size(), 1);
|
||||||
QCOMPARE(control->error(), QLowEnergyController::NoError);
|
QCOMPARE(control->error(), QLowEnergyController::NoError);
|
||||||
QVERIFY(control->errorString().isEmpty());
|
QVERIFY(control->errorString().isEmpty());
|
||||||
}
|
}
|
||||||
|
@ -314,15 +314,15 @@ void tst_QLowEnergyController::tst_connect()
|
||||||
QSignalSpy serviceFoundSpy(control.data(), SIGNAL(serviceDiscovered(QBluetoothUuid)));
|
QSignalSpy serviceFoundSpy(control.data(), SIGNAL(serviceDiscovered(QBluetoothUuid)));
|
||||||
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
||||||
control->discoverServices();
|
control->discoverServices();
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
|
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.size() == 1, 20000);
|
||||||
QCOMPARE(stateSpy.count(), 2);
|
QCOMPARE(stateSpy.size(), 2);
|
||||||
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
QLowEnergyController::DiscoveringState);
|
QLowEnergyController::DiscoveringState);
|
||||||
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
QLowEnergyController::DiscoveredState);
|
QLowEnergyController::DiscoveredState);
|
||||||
|
|
||||||
QVERIFY(!serviceFoundSpy.isEmpty());
|
QVERIFY(!serviceFoundSpy.isEmpty());
|
||||||
QVERIFY(serviceFoundSpy.count() >= foundServices.count());
|
QVERIFY(serviceFoundSpy.size() >= foundServices.size());
|
||||||
QVERIFY(!serviceFoundSpy.isEmpty());
|
QVERIFY(!serviceFoundSpy.isEmpty());
|
||||||
QList<QBluetoothUuid> listing;
|
QList<QBluetoothUuid> listing;
|
||||||
for (int i = 0; i < serviceFoundSpy.count(); i++) {
|
for (int i = 0; i < serviceFoundSpy.count(); i++) {
|
||||||
|
@ -359,8 +359,8 @@ void tst_QLowEnergyController::tst_connect()
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(
|
QTRY_VERIFY_WITH_TIMEOUT(
|
||||||
service->state() == QLowEnergyService::RemoteServiceDiscovered, 10000);
|
service->state() == QLowEnergyService::RemoteServiceDiscovered, 10000);
|
||||||
|
|
||||||
QCOMPARE(errorSpy.count(), 0); //no error
|
QCOMPARE(errorSpy.size(), 0); //no error
|
||||||
QCOMPARE(stateSpy.count(), 2); //
|
QCOMPARE(stateSpy.size(), 2); //
|
||||||
|
|
||||||
verifyServiceProperties(service);
|
verifyServiceProperties(service);
|
||||||
}
|
}
|
||||||
|
@ -382,9 +382,9 @@ void tst_QLowEnergyController::tst_connect()
|
||||||
10000);
|
10000);
|
||||||
|
|
||||||
if (wasError) {
|
if (wasError) {
|
||||||
QCOMPARE(disconnectedSpy.count(), 0);
|
QCOMPARE(disconnectedSpy.size(), 0);
|
||||||
} else {
|
} else {
|
||||||
QCOMPARE(disconnectedSpy.count(), 1);
|
QCOMPARE(disconnectedSpy.size(), 1);
|
||||||
// after disconnect all service references must be invalid
|
// after disconnect all service references must be invalid
|
||||||
for (const QLowEnergyService *entry : qAsConst(savedReferences)) {
|
for (const QLowEnergyService *entry : qAsConst(savedReferences)) {
|
||||||
const QBluetoothUuid &uuid = entry->serviceUuid();
|
const QBluetoothUuid &uuid = entry->serviceUuid();
|
||||||
|
@ -499,8 +499,8 @@ void tst_QLowEnergyController::tst_concurrentDiscovery()
|
||||||
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
||||||
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
||||||
control->discoverServices();
|
control->discoverServices();
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
|
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.size() == 1, 20000);
|
||||||
QCOMPARE(stateSpy.count(), 2);
|
QCOMPARE(stateSpy.size(), 2);
|
||||||
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
QLowEnergyController::DiscoveringState);
|
QLowEnergyController::DiscoveringState);
|
||||||
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
|
@ -511,7 +511,7 @@ void tst_QLowEnergyController::tst_concurrentDiscovery()
|
||||||
#define MAX_SERVICES_SAME_TIME_ACCESS 3
|
#define MAX_SERVICES_SAME_TIME_ACCESS 3
|
||||||
QLowEnergyService *services[MAX_SERVICES_SAME_TIME_ACCESS];
|
QLowEnergyService *services[MAX_SERVICES_SAME_TIME_ACCESS];
|
||||||
|
|
||||||
QVERIFY(control->services().count() >= MAX_SERVICES_SAME_TIME_ACCESS);
|
QVERIFY(control->services().size() >= MAX_SERVICES_SAME_TIME_ACCESS);
|
||||||
|
|
||||||
QList<QBluetoothUuid> uuids = control->services();
|
QList<QBluetoothUuid> uuids = control->services();
|
||||||
|
|
||||||
|
@ -557,8 +557,8 @@ void tst_QLowEnergyController::tst_concurrentDiscovery()
|
||||||
QCOMPARE(control->state(), QLowEnergyController::ConnectedState);
|
QCOMPARE(control->state(), QLowEnergyController::ConnectedState);
|
||||||
stateSpy.clear();
|
stateSpy.clear();
|
||||||
control->discoverServices();
|
control->discoverServices();
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
|
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.size() == 1, 20000);
|
||||||
QCOMPARE(stateSpy.count(), 2);
|
QCOMPARE(stateSpy.size(), 2);
|
||||||
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
QLowEnergyController::DiscoveringState);
|
QLowEnergyController::DiscoveringState);
|
||||||
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
|
@ -625,7 +625,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QBluetoothUuid(QString("00001800-0000-1000-8000-00805f9b34fb"))) {
|
QBluetoothUuid(QString("00001800-0000-1000-8000-00805f9b34fb"))) {
|
||||||
qDebug() << "Verifying GAP Service";
|
qDebug() << "Verifying GAP Service";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QCOMPARE(chars.count(), 5);
|
QCOMPARE(chars.size(), 5);
|
||||||
|
|
||||||
// Device Name
|
// Device Name
|
||||||
QString temp("00002a00-0000-1000-8000-00805f9b34fb");
|
QString temp("00002a00-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -633,7 +633,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[0].properties(), QLowEnergyCharacteristic::Read);
|
QCOMPARE(chars[0].properties(), QLowEnergyCharacteristic::Read);
|
||||||
QCOMPARE(chars[0].value(), QByteArray::fromHex("544920424c452053656e736f7220546167"));
|
QCOMPARE(chars[0].value(), QByteArray::fromHex("544920424c452053656e736f7220546167"));
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QCOMPARE(chars[0].descriptors().count(), 0);
|
QCOMPARE(chars[0].descriptors().size(), 0);
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
// Appearance
|
// Appearance
|
||||||
|
@ -642,7 +642,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[1].properties(), QLowEnergyCharacteristic::Read);
|
QCOMPARE(chars[1].properties(), QLowEnergyCharacteristic::Read);
|
||||||
QCOMPARE(chars[1].value(), QByteArray::fromHex("0000"));
|
QCOMPARE(chars[1].value(), QByteArray::fromHex("0000"));
|
||||||
QVERIFY(chars[1].isValid());
|
QVERIFY(chars[1].isValid());
|
||||||
QCOMPARE(chars[1].descriptors().count(), 0);
|
QCOMPARE(chars[1].descriptors().size(), 0);
|
||||||
QVERIFY(info->contains(chars[1]));
|
QVERIFY(info->contains(chars[1]));
|
||||||
|
|
||||||
// Peripheral Privacy Flag
|
// Peripheral Privacy Flag
|
||||||
|
@ -651,7 +651,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[2].properties() & QLowEnergyCharacteristic::Read);
|
QVERIFY(chars[2].properties() & QLowEnergyCharacteristic::Read);
|
||||||
QCOMPARE(chars[2].value(), QByteArray::fromHex("00"));
|
QCOMPARE(chars[2].value(), QByteArray::fromHex("00"));
|
||||||
QVERIFY(chars[2].isValid());
|
QVERIFY(chars[2].isValid());
|
||||||
QCOMPARE(chars[2].descriptors().count(), 0);
|
QCOMPARE(chars[2].descriptors().size(), 0);
|
||||||
QVERIFY(info->contains(chars[2]));
|
QVERIFY(info->contains(chars[2]));
|
||||||
|
|
||||||
// Reconnection Address
|
// Reconnection Address
|
||||||
|
@ -664,7 +664,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
else
|
else
|
||||||
QCOMPARE(chars[3].value(), QByteArray());
|
QCOMPARE(chars[3].value(), QByteArray());
|
||||||
QVERIFY(chars[3].isValid());
|
QVERIFY(chars[3].isValid());
|
||||||
QCOMPARE(chars[3].descriptors().count(), 0);
|
QCOMPARE(chars[3].descriptors().size(), 0);
|
||||||
QVERIFY(info->contains(chars[3]));
|
QVERIFY(info->contains(chars[3]));
|
||||||
|
|
||||||
// Peripheral Preferred Connection Parameters
|
// Peripheral Preferred Connection Parameters
|
||||||
|
@ -673,13 +673,13 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[4].properties(), QLowEnergyCharacteristic::Read);
|
QCOMPARE(chars[4].properties(), QLowEnergyCharacteristic::Read);
|
||||||
QCOMPARE(chars[4].value(), QByteArray::fromHex("5000a0000000e803"));
|
QCOMPARE(chars[4].value(), QByteArray::fromHex("5000a0000000e803"));
|
||||||
QVERIFY(chars[4].isValid());
|
QVERIFY(chars[4].isValid());
|
||||||
QCOMPARE(chars[4].descriptors().count(), 0);
|
QCOMPARE(chars[4].descriptors().size(), 0);
|
||||||
QVERIFY(info->contains(chars[4]));
|
QVERIFY(info->contains(chars[4]));
|
||||||
} else if (info->serviceUuid() ==
|
} else if (info->serviceUuid() ==
|
||||||
QBluetoothUuid(QString("00001801-0000-1000-8000-00805f9b34fb"))) {
|
QBluetoothUuid(QString("00001801-0000-1000-8000-00805f9b34fb"))) {
|
||||||
qDebug() << "Verifying GATT Service";
|
qDebug() << "Verifying GATT Service";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QCOMPARE(chars.count(), 1);
|
QCOMPARE(chars.size(), 1);
|
||||||
|
|
||||||
// Service Changed
|
// Service Changed
|
||||||
QString temp("00002a05-0000-1000-8000-00805f9b34fb");
|
QString temp("00002a05-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -690,7 +690,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().count(), 1);
|
QCOMPARE(chars[0].descriptors().size(), 1);
|
||||||
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
||||||
QCOMPARE(chars[0].descriptors().at(0).uuid(),
|
QCOMPARE(chars[0].descriptors().at(0).uuid(),
|
||||||
QBluetoothUuid(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration));
|
QBluetoothUuid(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration));
|
||||||
|
@ -702,7 +702,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QBluetoothUuid(QString("0000180a-0000-1000-8000-00805f9b34fb"))) {
|
QBluetoothUuid(QString("0000180a-0000-1000-8000-00805f9b34fb"))) {
|
||||||
qDebug() << "Verifying Device Information";
|
qDebug() << "Verifying Device Information";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QCOMPARE(chars.count(), 9);
|
QCOMPARE(chars.size(), 9);
|
||||||
|
|
||||||
// System ID
|
// System ID
|
||||||
QString temp("00002a23-0000-1000-8000-00805f9b34fb");
|
QString temp("00002a23-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -714,7 +714,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
// QCOMPARE(chars[0].value(), QByteArray::fromHex("6e41ab0000296abc"));
|
// QCOMPARE(chars[0].value(), QByteArray::fromHex("6e41ab0000296abc"));
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
QCOMPARE(chars[0].descriptors().count(), 0);
|
QCOMPARE(chars[0].descriptors().size(), 0);
|
||||||
|
|
||||||
// Model Number
|
// Model Number
|
||||||
temp = QString("00002a24-0000-1000-8000-00805f9b34fb");
|
temp = QString("00002a24-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -723,7 +723,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[1].value(), QByteArray::fromHex("4e2e412e00"));
|
QCOMPARE(chars[1].value(), QByteArray::fromHex("4e2e412e00"));
|
||||||
QVERIFY(chars[1].isValid());
|
QVERIFY(chars[1].isValid());
|
||||||
QVERIFY(info->contains(chars[1]));
|
QVERIFY(info->contains(chars[1]));
|
||||||
QCOMPARE(chars[1].descriptors().count(), 0);
|
QCOMPARE(chars[1].descriptors().size(), 0);
|
||||||
|
|
||||||
// Serial Number
|
// Serial Number
|
||||||
temp = QString("00002a25-0000-1000-8000-00805f9b34fb");
|
temp = QString("00002a25-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -733,7 +733,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[2].value(), QByteArray::fromHex("4e2e412e00"));
|
QCOMPARE(chars[2].value(), QByteArray::fromHex("4e2e412e00"));
|
||||||
QVERIFY(chars[2].isValid());
|
QVERIFY(chars[2].isValid());
|
||||||
QVERIFY(info->contains(chars[2]));
|
QVERIFY(info->contains(chars[2]));
|
||||||
QCOMPARE(chars[2].descriptors().count(), 0);
|
QCOMPARE(chars[2].descriptors().size(), 0);
|
||||||
|
|
||||||
// Firmware Revision
|
// Firmware Revision
|
||||||
temp = QString("00002a26-0000-1000-8000-00805f9b34fb");
|
temp = QString("00002a26-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -745,7 +745,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[3].value(), QByteArray::fromHex("312e3520284f637420323320323031332900"));
|
QCOMPARE(chars[3].value(), QByteArray::fromHex("312e3520284f637420323320323031332900"));
|
||||||
QVERIFY(chars[3].isValid());
|
QVERIFY(chars[3].isValid());
|
||||||
QVERIFY(info->contains(chars[3]));
|
QVERIFY(info->contains(chars[3]));
|
||||||
QCOMPARE(chars[3].descriptors().count(), 0);
|
QCOMPARE(chars[3].descriptors().size(), 0);
|
||||||
|
|
||||||
// Hardware Revision
|
// Hardware Revision
|
||||||
temp = QString("00002a27-0000-1000-8000-00805f9b34fb");
|
temp = QString("00002a27-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -755,7 +755,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[4].value(), QByteArray::fromHex("4e2e412e00"));
|
QCOMPARE(chars[4].value(), QByteArray::fromHex("4e2e412e00"));
|
||||||
QVERIFY(chars[4].isValid());
|
QVERIFY(chars[4].isValid());
|
||||||
QVERIFY(info->contains(chars[4]));
|
QVERIFY(info->contains(chars[4]));
|
||||||
QCOMPARE(chars[4].descriptors().count(), 0);
|
QCOMPARE(chars[4].descriptors().size(), 0);
|
||||||
|
|
||||||
// Software Revision
|
// Software Revision
|
||||||
temp = QString("00002a28-0000-1000-8000-00805f9b34fb");
|
temp = QString("00002a28-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -765,7 +765,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[5].value(), QByteArray::fromHex("4e2e412e00"));
|
QCOMPARE(chars[5].value(), QByteArray::fromHex("4e2e412e00"));
|
||||||
QVERIFY(chars[5].isValid());
|
QVERIFY(chars[5].isValid());
|
||||||
QVERIFY(info->contains(chars[5]));
|
QVERIFY(info->contains(chars[5]));
|
||||||
QCOMPARE(chars[5].descriptors().count(), 0);
|
QCOMPARE(chars[5].descriptors().size(), 0);
|
||||||
|
|
||||||
// Manufacturer Name
|
// Manufacturer Name
|
||||||
temp = QString("00002a29-0000-1000-8000-00805f9b34fb");
|
temp = QString("00002a29-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -775,7 +775,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[6].value(), QByteArray::fromHex("546578617320496e737472756d656e747300"));
|
QCOMPARE(chars[6].value(), QByteArray::fromHex("546578617320496e737472756d656e747300"));
|
||||||
QVERIFY(chars[6].isValid());
|
QVERIFY(chars[6].isValid());
|
||||||
QVERIFY(info->contains(chars[6]));
|
QVERIFY(info->contains(chars[6]));
|
||||||
QCOMPARE(chars[6].descriptors().count(), 0);
|
QCOMPARE(chars[6].descriptors().size(), 0);
|
||||||
|
|
||||||
// IEEE
|
// IEEE
|
||||||
temp = QString("00002a2a-0000-1000-8000-00805f9b34fb");
|
temp = QString("00002a2a-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -785,7 +785,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[7].value(), QByteArray::fromHex("fe006578706572696d656e74616c"));
|
QCOMPARE(chars[7].value(), QByteArray::fromHex("fe006578706572696d656e74616c"));
|
||||||
QVERIFY(chars[7].isValid());
|
QVERIFY(chars[7].isValid());
|
||||||
QVERIFY(info->contains(chars[7]));
|
QVERIFY(info->contains(chars[7]));
|
||||||
QCOMPARE(chars[7].descriptors().count(), 0);
|
QCOMPARE(chars[7].descriptors().size(), 0);
|
||||||
|
|
||||||
// PnP ID
|
// PnP ID
|
||||||
temp = QString("00002a50-0000-1000-8000-00805f9b34fb");
|
temp = QString("00002a50-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -795,12 +795,12 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[8].value(), QByteArray::fromHex("010d0000001001"));
|
QCOMPARE(chars[8].value(), QByteArray::fromHex("010d0000001001"));
|
||||||
QVERIFY(chars[8].isValid());
|
QVERIFY(chars[8].isValid());
|
||||||
QVERIFY(info->contains(chars[8]));
|
QVERIFY(info->contains(chars[8]));
|
||||||
QCOMPARE(chars[8].descriptors().count(), 0);
|
QCOMPARE(chars[8].descriptors().size(), 0);
|
||||||
} else if (info->serviceUuid() ==
|
} else if (info->serviceUuid() ==
|
||||||
QBluetoothUuid(QString("f000aa00-0451-4000-b000-000000000000"))) {
|
QBluetoothUuid(QString("f000aa00-0451-4000-b000-000000000000"))) {
|
||||||
qDebug() << "Verifying Temperature";
|
qDebug() << "Verifying Temperature";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QVERIFY(chars.count() >= 2);
|
QVERIFY(chars.size() >= 2);
|
||||||
|
|
||||||
// Temp Data
|
// Temp Data
|
||||||
QString temp("f000aa01-0451-4000-b000-000000000000");
|
QString temp("f000aa01-0451-4000-b000-000000000000");
|
||||||
|
@ -811,7 +811,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().count(), 2);
|
QCOMPARE(chars[0].descriptors().size(), 2);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
||||||
QCOMPARE(chars[0].descriptors().at(0).uuid(),
|
QCOMPARE(chars[0].descriptors().at(0).uuid(),
|
||||||
|
@ -840,7 +840,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[1].isValid());
|
QVERIFY(chars[1].isValid());
|
||||||
QVERIFY(info->contains(chars[1]));
|
QVERIFY(info->contains(chars[1]));
|
||||||
|
|
||||||
QCOMPARE(chars[1].descriptors().count(), 1);
|
QCOMPARE(chars[1].descriptors().size(), 1);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
||||||
QCOMPARE(chars[1].descriptors().at(0).uuid(),
|
QCOMPARE(chars[1].descriptors().at(0).uuid(),
|
||||||
|
@ -854,7 +854,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
|
|
||||||
|
|
||||||
//Temp Period (introduced by later firmware versions)
|
//Temp Period (introduced by later firmware versions)
|
||||||
if (chars.count() > 2) {
|
if (chars.size() > 2) {
|
||||||
temp = QString("f000aa03-0451-4000-b000-000000000000");
|
temp = QString("f000aa03-0451-4000-b000-000000000000");
|
||||||
QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp));
|
QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp));
|
||||||
QCOMPARE(chars[2].properties(),
|
QCOMPARE(chars[2].properties(),
|
||||||
|
@ -863,7 +863,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[2].isValid());
|
QVERIFY(chars[2].isValid());
|
||||||
QVERIFY(info->contains(chars[2]));
|
QVERIFY(info->contains(chars[2]));
|
||||||
|
|
||||||
QCOMPARE(chars[2].descriptors().count(), 1);
|
QCOMPARE(chars[2].descriptors().size(), 1);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
||||||
QCOMPARE(chars[2].descriptors().at(0).uuid(),
|
QCOMPARE(chars[2].descriptors().at(0).uuid(),
|
||||||
|
@ -878,7 +878,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QBluetoothUuid(QString("0000ffe0-0000-1000-8000-00805f9b34fb"))) {
|
QBluetoothUuid(QString("0000ffe0-0000-1000-8000-00805f9b34fb"))) {
|
||||||
qDebug() << "Verifying Simple Keys";
|
qDebug() << "Verifying Simple Keys";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QCOMPARE(chars.count(), 1);
|
QCOMPARE(chars.size(), 1);
|
||||||
|
|
||||||
// Temp Data
|
// Temp Data
|
||||||
QString temp("0000ffe1-0000-1000-8000-00805f9b34fb");
|
QString temp("0000ffe1-0000-1000-8000-00805f9b34fb");
|
||||||
|
@ -890,7 +890,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().count(), 2);
|
QCOMPARE(chars[0].descriptors().size(), 2);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -915,7 +915,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QBluetoothUuid(QString("f000aa10-0451-4000-b000-000000000000"))) {
|
QBluetoothUuid(QString("f000aa10-0451-4000-b000-000000000000"))) {
|
||||||
qDebug() << "Verifying Accelerometer";
|
qDebug() << "Verifying Accelerometer";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QCOMPARE(chars.count(), 3);
|
QCOMPARE(chars.size(), 3);
|
||||||
|
|
||||||
// Accel Data
|
// Accel Data
|
||||||
QString temp("f000aa11-0451-4000-b000-000000000000");
|
QString temp("f000aa11-0451-4000-b000-000000000000");
|
||||||
|
@ -927,7 +927,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().count(), 2);
|
QCOMPARE(chars[0].descriptors().size(), 2);
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -957,7 +957,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QCOMPARE(chars[1].value(), QByteArray::fromHex("00"));
|
QCOMPARE(chars[1].value(), QByteArray::fromHex("00"));
|
||||||
QVERIFY(chars[1].isValid());
|
QVERIFY(chars[1].isValid());
|
||||||
QVERIFY(info->contains(chars[1]));
|
QVERIFY(info->contains(chars[1]));
|
||||||
QCOMPARE(chars[1].descriptors().count(), 1);
|
QCOMPARE(chars[1].descriptors().size(), 1);
|
||||||
|
|
||||||
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -979,7 +979,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[2].isValid());
|
QVERIFY(chars[2].isValid());
|
||||||
QVERIFY(info->contains(chars[2]));
|
QVERIFY(info->contains(chars[2]));
|
||||||
|
|
||||||
QCOMPARE(chars[2].descriptors().count(), 1);
|
QCOMPARE(chars[2].descriptors().size(), 1);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -995,7 +995,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QBluetoothUuid(QString("f000aa20-0451-4000-b000-000000000000"))) {
|
QBluetoothUuid(QString("f000aa20-0451-4000-b000-000000000000"))) {
|
||||||
qDebug() << "Verifying Humidity";
|
qDebug() << "Verifying Humidity";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QVERIFY(chars.count() >= 2); //new firmware has more chars
|
QVERIFY(chars.size() >= 2); //new firmware has more chars
|
||||||
|
|
||||||
// Humidity Data
|
// Humidity Data
|
||||||
QString temp("f000aa21-0451-4000-b000-000000000000");
|
QString temp("f000aa21-0451-4000-b000-000000000000");
|
||||||
|
@ -1007,7 +1007,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().count(), 2);
|
QCOMPARE(chars[0].descriptors().size(), 2);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -1038,7 +1038,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[1].isValid());
|
QVERIFY(chars[1].isValid());
|
||||||
QVERIFY(info->contains(chars[1]));
|
QVERIFY(info->contains(chars[1]));
|
||||||
|
|
||||||
QCOMPARE(chars[1].descriptors().count(), 1);
|
QCOMPARE(chars[1].descriptors().size(), 1);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -1050,7 +1050,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QByteArray::fromHex("48756d69642e20436f6e662e"));
|
QByteArray::fromHex("48756d69642e20436f6e662e"));
|
||||||
QVERIFY(info->contains(chars[1].descriptors().at(0)));
|
QVERIFY(info->contains(chars[1].descriptors().at(0)));
|
||||||
|
|
||||||
if (chars.count() >= 3) {
|
if (chars.size() >= 3) {
|
||||||
// New firmware new characteristic
|
// New firmware new characteristic
|
||||||
// Humidity Period
|
// Humidity Period
|
||||||
temp = QString("f000aa23-0451-4000-b000-000000000000");
|
temp = QString("f000aa23-0451-4000-b000-000000000000");
|
||||||
|
@ -1061,7 +1061,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[2].isValid());
|
QVERIFY(chars[2].isValid());
|
||||||
QVERIFY(info->contains(chars[2]));
|
QVERIFY(info->contains(chars[2]));
|
||||||
|
|
||||||
QCOMPARE(chars[2].descriptors().count(), 1);
|
QCOMPARE(chars[2].descriptors().size(), 1);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
||||||
QCOMPARE(chars[2].descriptors().at(0).uuid(),
|
QCOMPARE(chars[2].descriptors().at(0).uuid(),
|
||||||
|
@ -1076,7 +1076,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QBluetoothUuid(QString("f000aa30-0451-4000-b000-000000000000"))) {
|
QBluetoothUuid(QString("f000aa30-0451-4000-b000-000000000000"))) {
|
||||||
qDebug() << "Verifying Magnetometer";
|
qDebug() << "Verifying Magnetometer";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QCOMPARE(chars.count(), 3);
|
QCOMPARE(chars.size(), 3);
|
||||||
|
|
||||||
// Magnetometer Data
|
// Magnetometer Data
|
||||||
QString temp("f000aa31-0451-4000-b000-000000000000");
|
QString temp("f000aa31-0451-4000-b000-000000000000");
|
||||||
|
@ -1088,7 +1088,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().count(), 2);
|
QCOMPARE(chars[0].descriptors().size(), 2);
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -1119,7 +1119,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[1].isValid());
|
QVERIFY(chars[1].isValid());
|
||||||
QVERIFY(info->contains(chars[1]));
|
QVERIFY(info->contains(chars[1]));
|
||||||
|
|
||||||
QCOMPARE(chars[1].descriptors().count(), 1);
|
QCOMPARE(chars[1].descriptors().size(), 1);
|
||||||
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
QCOMPARE(chars[1].descriptors().at(0).uuid(),
|
QCOMPARE(chars[1].descriptors().at(0).uuid(),
|
||||||
|
@ -1141,7 +1141,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[2].isValid());
|
QVERIFY(chars[2].isValid());
|
||||||
QVERIFY(info->contains(chars[2]));
|
QVERIFY(info->contains(chars[2]));
|
||||||
|
|
||||||
QCOMPARE(chars[2].descriptors().count(), 1);
|
QCOMPARE(chars[2].descriptors().size(), 1);
|
||||||
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
QCOMPARE(chars[2].descriptors().at(0).uuid(),
|
QCOMPARE(chars[2].descriptors().at(0).uuid(),
|
||||||
|
@ -1156,7 +1156,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QBluetoothUuid(QString("f000aa40-0451-4000-b000-000000000000"))) {
|
QBluetoothUuid(QString("f000aa40-0451-4000-b000-000000000000"))) {
|
||||||
qDebug() << "Verifying Pressure";
|
qDebug() << "Verifying Pressure";
|
||||||
const QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
const QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QVERIFY(chars.count() >= 3);
|
QVERIFY(chars.size() >= 3);
|
||||||
|
|
||||||
// Pressure Data
|
// Pressure Data
|
||||||
QString temp("f000aa41-0451-4000-b000-000000000000");
|
QString temp("f000aa41-0451-4000-b000-000000000000");
|
||||||
|
@ -1168,7 +1168,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().count(), 2);
|
QCOMPARE(chars[0].descriptors().size(), 2);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -1200,7 +1200,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[1].isValid());
|
QVERIFY(chars[1].isValid());
|
||||||
QVERIFY(info->contains(chars[1]));
|
QVERIFY(info->contains(chars[1]));
|
||||||
|
|
||||||
QCOMPARE(chars[1].descriptors().count(), 1);
|
QCOMPARE(chars[1].descriptors().size(), 1);
|
||||||
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
QCOMPARE(chars[1].descriptors().at(0).uuid(),
|
QCOMPARE(chars[1].descriptors().at(0).uuid(),
|
||||||
|
@ -1232,7 +1232,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(calibration.isValid());
|
QVERIFY(calibration.isValid());
|
||||||
QVERIFY(info->contains(calibration));
|
QVERIFY(info->contains(calibration));
|
||||||
|
|
||||||
QCOMPARE(calibration.descriptors().count(), 2);
|
QCOMPARE(calibration.descriptors().size(), 2);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(calibration.descriptors().at(0).isValid(), true);
|
QCOMPARE(calibration.descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -1266,7 +1266,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(period.isValid());
|
QVERIFY(period.isValid());
|
||||||
QVERIFY(info->contains(period));
|
QVERIFY(info->contains(period));
|
||||||
|
|
||||||
QCOMPARE(period.descriptors().count(), 1);
|
QCOMPARE(period.descriptors().size(), 1);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(period.descriptors().at(0).isValid(), true);
|
QCOMPARE(period.descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -1282,7 +1282,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QBluetoothUuid(QString("f000aa50-0451-4000-b000-000000000000"))) {
|
QBluetoothUuid(QString("f000aa50-0451-4000-b000-000000000000"))) {
|
||||||
qDebug() << "Verifying Gyroscope";
|
qDebug() << "Verifying Gyroscope";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QVERIFY(chars.count() >= 2);
|
QVERIFY(chars.size() >= 2);
|
||||||
|
|
||||||
// Gyroscope Data
|
// Gyroscope Data
|
||||||
QString temp("f000aa51-0451-4000-b000-000000000000");
|
QString temp("f000aa51-0451-4000-b000-000000000000");
|
||||||
|
@ -1294,7 +1294,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().count(), 2);
|
QCOMPARE(chars[0].descriptors().size(), 2);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -1326,7 +1326,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[1].isValid());
|
QVERIFY(chars[1].isValid());
|
||||||
QVERIFY(info->contains(chars[1]));
|
QVERIFY(info->contains(chars[1]));
|
||||||
|
|
||||||
QCOMPARE(chars[1].descriptors().count(), 1);
|
QCOMPARE(chars[1].descriptors().size(), 1);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -1348,7 +1348,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[2].isValid());
|
QVERIFY(chars[2].isValid());
|
||||||
QVERIFY(info->contains(chars[2]));
|
QVERIFY(info->contains(chars[2]));
|
||||||
|
|
||||||
QCOMPARE(chars[2].descriptors().count(), 1);
|
QCOMPARE(chars[2].descriptors().size(), 1);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
||||||
QCOMPARE(chars[2].descriptors().at(0).uuid(),
|
QCOMPARE(chars[2].descriptors().at(0).uuid(),
|
||||||
|
@ -1362,7 +1362,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QBluetoothUuid(QString("f000aa60-0451-4000-b000-000000000000"))) {
|
QBluetoothUuid(QString("f000aa60-0451-4000-b000-000000000000"))) {
|
||||||
qDebug() << "Verifying Test Service";
|
qDebug() << "Verifying Test Service";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QCOMPARE(chars.count(), 2);
|
QCOMPARE(chars.size(), 2);
|
||||||
|
|
||||||
// Test Data
|
// Test Data
|
||||||
QString temp("f000aa61-0451-4000-b000-000000000000");
|
QString temp("f000aa61-0451-4000-b000-000000000000");
|
||||||
|
@ -1374,7 +1374,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().count(), 1);
|
QCOMPARE(chars[0].descriptors().size(), 1);
|
||||||
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
QCOMPARE(chars[0].descriptors().at(0).uuid(),
|
QCOMPARE(chars[0].descriptors().at(0).uuid(),
|
||||||
|
@ -1394,7 +1394,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[1].isValid());
|
QVERIFY(chars[1].isValid());
|
||||||
QVERIFY(info->contains(chars[1]));
|
QVERIFY(info->contains(chars[1]));
|
||||||
|
|
||||||
QCOMPARE(chars[1].descriptors().count(), 1);
|
QCOMPARE(chars[1].descriptors().size(), 1);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -1409,7 +1409,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QBluetoothUuid(QString("f000ccc0-0451-4000-b000-000000000000"))) {
|
QBluetoothUuid(QString("f000ccc0-0451-4000-b000-000000000000"))) {
|
||||||
qDebug() << "Connection Control Service";
|
qDebug() << "Connection Control Service";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QCOMPARE(chars.count(), 3);
|
QCOMPARE(chars.size(), 3);
|
||||||
|
|
||||||
//first characteristic
|
//first characteristic
|
||||||
QString temp("f000ccc1-0451-4000-b000-000000000000");
|
QString temp("f000ccc1-0451-4000-b000-000000000000");
|
||||||
|
@ -1422,7 +1422,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().count(), 2);
|
QCOMPARE(chars[0].descriptors().size(), 2);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
||||||
QCOMPARE(chars[0].descriptors().at(0).uuid(),
|
QCOMPARE(chars[0].descriptors().at(0).uuid(),
|
||||||
|
@ -1450,7 +1450,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[1].isValid());
|
QVERIFY(chars[1].isValid());
|
||||||
QVERIFY(info->contains(chars[1]));
|
QVERIFY(info->contains(chars[1]));
|
||||||
|
|
||||||
QCOMPARE(chars[1].descriptors().count(), 1);
|
QCOMPARE(chars[1].descriptors().size(), 1);
|
||||||
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
||||||
QCOMPARE(chars[1].descriptors().at(0).uuid(),
|
QCOMPARE(chars[1].descriptors().at(0).uuid(),
|
||||||
QBluetoothUuid(QBluetoothUuid::DescriptorType::CharacteristicUserDescription));
|
QBluetoothUuid(QBluetoothUuid::DescriptorType::CharacteristicUserDescription));
|
||||||
|
@ -1468,7 +1468,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[2].isValid());
|
QVERIFY(chars[2].isValid());
|
||||||
QVERIFY(info->contains(chars[2]));
|
QVERIFY(info->contains(chars[2]));
|
||||||
|
|
||||||
QCOMPARE(chars[2].descriptors().count(), 1);
|
QCOMPARE(chars[2].descriptors().size(), 1);
|
||||||
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
|
||||||
QCOMPARE(chars[2].descriptors().at(0).uuid(),
|
QCOMPARE(chars[2].descriptors().at(0).uuid(),
|
||||||
QBluetoothUuid(QBluetoothUuid::DescriptorType::CharacteristicUserDescription));
|
QBluetoothUuid(QBluetoothUuid::DescriptorType::CharacteristicUserDescription));
|
||||||
|
@ -1481,7 +1481,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QBluetoothUuid(QString("f000ffc0-0451-4000-b000-000000000000"))) {
|
QBluetoothUuid(QString("f000ffc0-0451-4000-b000-000000000000"))) {
|
||||||
qDebug() << "Verifying OID Service";
|
qDebug() << "Verifying OID Service";
|
||||||
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
QList<QLowEnergyCharacteristic> chars = info->characteristics();
|
||||||
QCOMPARE(chars.count(), 2);
|
QCOMPARE(chars.size(), 2);
|
||||||
|
|
||||||
// first characteristic
|
// first characteristic
|
||||||
QString temp("f000ffc1-0451-4000-b000-000000000000");
|
QString temp("f000ffc1-0451-4000-b000-000000000000");
|
||||||
|
@ -1493,7 +1493,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[0].isValid());
|
QVERIFY(chars[0].isValid());
|
||||||
QVERIFY(info->contains(chars[0]));
|
QVERIFY(info->contains(chars[0]));
|
||||||
|
|
||||||
QCOMPARE(chars[0].descriptors().count(), 2);
|
QCOMPARE(chars[0].descriptors().size(), 2);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
|
||||||
QCOMPARE(chars[0].descriptors().at(0).uuid(),
|
QCOMPARE(chars[0].descriptors().at(0).uuid(),
|
||||||
|
@ -1523,7 +1523,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
|
||||||
QVERIFY(chars[1].isValid());
|
QVERIFY(chars[1].isValid());
|
||||||
QVERIFY(info->contains(chars[1]));
|
QVERIFY(info->contains(chars[1]));
|
||||||
|
|
||||||
QCOMPARE(chars[1].descriptors().count(), 2);
|
QCOMPARE(chars[1].descriptors().size(), 2);
|
||||||
//descriptor checks
|
//descriptor checks
|
||||||
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
|
||||||
// value different in other revisions and test may fail
|
// value different in other revisions and test may fail
|
||||||
|
@ -1601,7 +1601,7 @@ void tst_QLowEnergyController::tst_defaultBehavior()
|
||||||
QBluetoothUuid(QBluetoothUuid::CharacteristicType::DeviceName)));
|
QBluetoothUuid(QBluetoothUuid::CharacteristicType::DeviceName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QCOMPARE(controlDefaultAdapter->services().count(), 0);
|
QCOMPARE(controlDefaultAdapter->services().size(), 0);
|
||||||
|
|
||||||
// Test explicit local adapter
|
// Test explicit local adapter
|
||||||
if (!foundAddresses.isEmpty()) {
|
if (!foundAddresses.isEmpty()) {
|
||||||
|
@ -1615,7 +1615,7 @@ void tst_QLowEnergyController::tst_defaultBehavior()
|
||||||
QCOMPARE(controlExplicitAdapter->localAddress(), foundAddresses[0]);
|
QCOMPARE(controlExplicitAdapter->localAddress(), foundAddresses[0]);
|
||||||
QCOMPARE(controlExplicitAdapter->state(),
|
QCOMPARE(controlExplicitAdapter->state(),
|
||||||
QLowEnergyController::UnconnectedState);
|
QLowEnergyController::UnconnectedState);
|
||||||
QCOMPARE(controlExplicitAdapter->services().count(), 0);
|
QCOMPARE(controlExplicitAdapter->services().size(), 0);
|
||||||
|
|
||||||
// unrelated uuids don't return valid service object
|
// unrelated uuids don't return valid service object
|
||||||
// invalid service uuid
|
// invalid service uuid
|
||||||
|
@ -1658,8 +1658,8 @@ void tst_QLowEnergyController::tst_writeCharacteristic()
|
||||||
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
||||||
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
||||||
control->discoverServices();
|
control->discoverServices();
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
|
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.size() == 1, 20000);
|
||||||
QCOMPARE(stateSpy.count(), 2);
|
QCOMPARE(stateSpy.size(), 2);
|
||||||
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
QLowEnergyController::DiscoveringState);
|
QLowEnergyController::DiscoveringState);
|
||||||
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
|
@ -1728,7 +1728,7 @@ void tst_QLowEnergyController::tst_writeCharacteristic()
|
||||||
service->readCharacteristic(configChar);
|
service->readCharacteristic(configChar);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!readSpy.isEmpty(), 10000);
|
QTRY_VERIFY_WITH_TIMEOUT(!readSpy.isEmpty(), 10000);
|
||||||
QCOMPARE(configChar.value(), QByteArray::fromHex("81"));
|
QCOMPARE(configChar.value(), QByteArray::fromHex("81"));
|
||||||
QCOMPARE(readSpy.count(), 1); //expect one characteristicRead signal
|
QCOMPARE(readSpy.size(), 1); //expect one characteristicRead signal
|
||||||
{
|
{
|
||||||
//verify the readCharacteristic()
|
//verify the readCharacteristic()
|
||||||
QList<QVariant> firstSignalData = readSpy.first();
|
QList<QVariant> firstSignalData = readSpy.first();
|
||||||
|
@ -1754,8 +1754,8 @@ void tst_QLowEnergyController::tst_writeCharacteristic()
|
||||||
// write wrong value -> error response required
|
// write wrong value -> error response required
|
||||||
QSignalSpy errorSpy(service, SIGNAL(errorOccurred(QLowEnergyService::ServiceError)));
|
QSignalSpy errorSpy(service, SIGNAL(errorOccurred(QLowEnergyService::ServiceError)));
|
||||||
writeSpy.clear();
|
writeSpy.clear();
|
||||||
QCOMPARE(errorSpy.count(), 0);
|
QCOMPARE(errorSpy.size(), 0);
|
||||||
QCOMPARE(writeSpy.count(), 0);
|
QCOMPARE(writeSpy.size(), 0);
|
||||||
|
|
||||||
// write 2 byte value to 1 byte characteristic
|
// write 2 byte value to 1 byte characteristic
|
||||||
service->writeCharacteristic(configChar, QByteArray::fromHex("1111"));
|
service->writeCharacteristic(configChar, QByteArray::fromHex("1111"));
|
||||||
|
@ -1763,20 +1763,20 @@ void tst_QLowEnergyController::tst_writeCharacteristic()
|
||||||
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
QLowEnergyService::CharacteristicWriteError);
|
QLowEnergyService::CharacteristicWriteError);
|
||||||
QCOMPARE(service->error(), QLowEnergyService::CharacteristicWriteError);
|
QCOMPARE(service->error(), QLowEnergyService::CharacteristicWriteError);
|
||||||
QCOMPARE(writeSpy.count(), 0);
|
QCOMPARE(writeSpy.size(), 0);
|
||||||
QCOMPARE(configChar.value(), QByteArray::fromHex("00"));
|
QCOMPARE(configChar.value(), QByteArray::fromHex("00"));
|
||||||
|
|
||||||
// *******************************************
|
// *******************************************
|
||||||
// write to read-only characteristic -> error
|
// write to read-only characteristic -> error
|
||||||
errorSpy.clear();
|
errorSpy.clear();
|
||||||
QCOMPARE(errorSpy.count(), 0);
|
QCOMPARE(errorSpy.size(), 0);
|
||||||
service->writeCharacteristic(dataChar, QByteArray::fromHex("ffff"));
|
service->writeCharacteristic(dataChar, QByteArray::fromHex("ffff"));
|
||||||
|
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000);
|
QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000);
|
||||||
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
QLowEnergyService::CharacteristicWriteError);
|
QLowEnergyService::CharacteristicWriteError);
|
||||||
QCOMPARE(service->error(), QLowEnergyService::CharacteristicWriteError);
|
QCOMPARE(service->error(), QLowEnergyService::CharacteristicWriteError);
|
||||||
QCOMPARE(writeSpy.count(), 0);
|
QCOMPARE(writeSpy.size(), 0);
|
||||||
QCOMPARE(dataChar.value(), QByteArray::fromHex("3f00"));
|
QCOMPARE(dataChar.value(), QByteArray::fromHex("3f00"));
|
||||||
|
|
||||||
|
|
||||||
|
@ -1786,13 +1786,13 @@ void tst_QLowEnergyController::tst_writeCharacteristic()
|
||||||
// *******************************************
|
// *******************************************
|
||||||
// write value while disconnected -> error
|
// write value while disconnected -> error
|
||||||
errorSpy.clear();
|
errorSpy.clear();
|
||||||
QCOMPARE(errorSpy.count(), 0);
|
QCOMPARE(errorSpy.size(), 0);
|
||||||
service->writeCharacteristic(configChar, QByteArray::fromHex("ffff"));
|
service->writeCharacteristic(configChar, QByteArray::fromHex("ffff"));
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 2000);
|
QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 2000);
|
||||||
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
QLowEnergyService::OperationError);
|
QLowEnergyService::OperationError);
|
||||||
QCOMPARE(service->error(), QLowEnergyService::OperationError);
|
QCOMPARE(service->error(), QLowEnergyService::OperationError);
|
||||||
QCOMPARE(writeSpy.count(), 0);
|
QCOMPARE(writeSpy.size(), 0);
|
||||||
QCOMPARE(configChar.value(), QByteArray::fromHex("00"));
|
QCOMPARE(configChar.value(), QByteArray::fromHex("00"));
|
||||||
|
|
||||||
// invalid characteristics still belong to their respective service
|
// invalid characteristics still belong to their respective service
|
||||||
|
@ -1833,8 +1833,8 @@ void tst_QLowEnergyController::tst_readWriteDescriptor()
|
||||||
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
||||||
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
||||||
control->discoverServices();
|
control->discoverServices();
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
|
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.size() == 1, 20000);
|
||||||
QCOMPARE(stateSpy.count(), 2);
|
QCOMPARE(stateSpy.size(), 2);
|
||||||
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
QLowEnergyController::DiscoveringState);
|
QLowEnergyController::DiscoveringState);
|
||||||
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
|
@ -1921,10 +1921,10 @@ void tst_QLowEnergyController::tst_readWriteDescriptor()
|
||||||
|
|
||||||
// first signal is confirmation of humidConfig write
|
// first signal is confirmation of humidConfig write
|
||||||
// subsequent signals are temp data updates
|
// subsequent signals are temp data updates
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(charWrittenSpy.count() == 1, 10000);
|
QTRY_VERIFY_WITH_TIMEOUT(charWrittenSpy.size() == 1, 10000);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(charChangedSpy.count() >= 4, 10000);
|
QTRY_VERIFY_WITH_TIMEOUT(charChangedSpy.size() >= 4, 10000);
|
||||||
|
|
||||||
QCOMPARE(charWrittenSpy.count(), 1);
|
QCOMPARE(charWrittenSpy.size(), 1);
|
||||||
QLowEnergyCharacteristic writtenChar = charWrittenSpy[0].at(0).value<QLowEnergyCharacteristic>();
|
QLowEnergyCharacteristic writtenChar = charWrittenSpy[0].at(0).value<QLowEnergyCharacteristic>();
|
||||||
QByteArray writtenValue = charWrittenSpy[0].at(1).toByteArray();
|
QByteArray writtenValue = charWrittenSpy[0].at(1).toByteArray();
|
||||||
QCOMPARE(humidConfig, writtenChar);
|
QCOMPARE(humidConfig, writtenChar);
|
||||||
|
@ -1940,7 +1940,7 @@ void tst_QLowEnergyController::tst_readWriteDescriptor()
|
||||||
QCOMPARE(humidData, ch);
|
QCOMPARE(humidData, ch);
|
||||||
|
|
||||||
//check last characteristic changed value matches the characteristics current value
|
//check last characteristic changed value matches the characteristics current value
|
||||||
if (i == (charChangedSpy.count() - 1)) {
|
if (i == (charChangedSpy.size() - 1)) {
|
||||||
writtenValue = entry[1].toByteArray();
|
writtenValue = entry[1].toByteArray();
|
||||||
QCOMPARE(ch.value(), writtenValue);
|
QCOMPARE(ch.value(), writtenValue);
|
||||||
QCOMPARE(humidData.value(), writtenValue);
|
QCOMPARE(humidData.value(), writtenValue);
|
||||||
|
@ -1954,7 +1954,7 @@ void tst_QLowEnergyController::tst_readWriteDescriptor()
|
||||||
|
|
||||||
service->readDescriptor(notification);
|
service->readDescriptor(notification);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!descReadSpy.isEmpty(), 3000);
|
QTRY_VERIFY_WITH_TIMEOUT(!descReadSpy.isEmpty(), 3000);
|
||||||
QCOMPARE(descReadSpy.count(), 1);
|
QCOMPARE(descReadSpy.size(), 1);
|
||||||
firstSignalData = descReadSpy.first();
|
firstSignalData = descReadSpy.first();
|
||||||
signalDesc = firstSignalData[0].value<QLowEnergyDescriptor>();
|
signalDesc = firstSignalData[0].value<QLowEnergyDescriptor>();
|
||||||
signalValue = firstSignalData[1].toByteArray();
|
signalValue = firstSignalData[1].toByteArray();
|
||||||
|
@ -1998,7 +1998,7 @@ void tst_QLowEnergyController::tst_readWriteDescriptor()
|
||||||
if (isBluezDbusLE)
|
if (isBluezDbusLE)
|
||||||
QTest::qWait(1000);
|
QTest::qWait(1000);
|
||||||
|
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(descWrittenSpy.count() == 4, 10000);
|
QTRY_VERIFY_WITH_TIMEOUT(descWrittenSpy.size() == 4, 10000);
|
||||||
|
|
||||||
QCOMPARE(notification.value(), QByteArray::fromHex("0000"));
|
QCOMPARE(notification.value(), QByteArray::fromHex("0000"));
|
||||||
for (int i = 0; i < descWrittenSpy.count(); i++) {
|
for (int i = 0; i < descWrittenSpy.count(); i++) {
|
||||||
|
@ -2017,7 +2017,7 @@ void tst_QLowEnergyController::tst_readWriteDescriptor()
|
||||||
|
|
||||||
service->readDescriptor(notification);
|
service->readDescriptor(notification);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!descReadSpy.isEmpty(), 3000);
|
QTRY_VERIFY_WITH_TIMEOUT(!descReadSpy.isEmpty(), 3000);
|
||||||
QCOMPARE(descReadSpy.count(), 1);
|
QCOMPARE(descReadSpy.size(), 1);
|
||||||
firstSignalData = descReadSpy.first();
|
firstSignalData = descReadSpy.first();
|
||||||
signalDesc = firstSignalData[0].value<QLowEnergyDescriptor>();
|
signalDesc = firstSignalData[0].value<QLowEnergyDescriptor>();
|
||||||
signalValue = firstSignalData[1].toByteArray();
|
signalValue = firstSignalData[1].toByteArray();
|
||||||
|
@ -2031,8 +2031,8 @@ void tst_QLowEnergyController::tst_readWriteDescriptor()
|
||||||
// write wrong value -> error response required
|
// write wrong value -> error response required
|
||||||
QSignalSpy errorSpy(service, SIGNAL(errorOccurred(QLowEnergyService::ServiceError)));
|
QSignalSpy errorSpy(service, SIGNAL(errorOccurred(QLowEnergyService::ServiceError)));
|
||||||
descWrittenSpy.clear();
|
descWrittenSpy.clear();
|
||||||
QCOMPARE(errorSpy.count(), 0);
|
QCOMPARE(errorSpy.size(), 0);
|
||||||
QCOMPARE(descWrittenSpy.count(), 0);
|
QCOMPARE(descWrittenSpy.size(), 0);
|
||||||
|
|
||||||
// write 4 byte value to 2 byte characteristic
|
// write 4 byte value to 2 byte characteristic
|
||||||
service->writeDescriptor(notification, QByteArray::fromHex("11112222"));
|
service->writeDescriptor(notification, QByteArray::fromHex("11112222"));
|
||||||
|
@ -2048,7 +2048,7 @@ void tst_QLowEnergyController::tst_readWriteDescriptor()
|
||||||
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
QLowEnergyService::DescriptorWriteError);
|
QLowEnergyService::DescriptorWriteError);
|
||||||
QCOMPARE(service->error(), QLowEnergyService::DescriptorWriteError);
|
QCOMPARE(service->error(), QLowEnergyService::DescriptorWriteError);
|
||||||
QCOMPARE(descWrittenSpy.count(), 0);
|
QCOMPARE(descWrittenSpy.size(), 0);
|
||||||
QCOMPARE(notification.value(), QByteArray::fromHex("0000"));
|
QCOMPARE(notification.value(), QByteArray::fromHex("0000"));
|
||||||
|
|
||||||
control->disconnectFromDevice();
|
control->disconnectFromDevice();
|
||||||
|
@ -2063,7 +2063,7 @@ void tst_QLowEnergyController::tst_readWriteDescriptor()
|
||||||
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
QLowEnergyService::OperationError);
|
QLowEnergyService::OperationError);
|
||||||
QCOMPARE(service->error(), QLowEnergyService::OperationError);
|
QCOMPARE(service->error(), QLowEnergyService::OperationError);
|
||||||
QCOMPARE(descWrittenSpy.count(), 0);
|
QCOMPARE(descWrittenSpy.size(), 0);
|
||||||
QCOMPARE(notification.value(), QByteArray::fromHex("0000"));
|
QCOMPARE(notification.value(), QByteArray::fromHex("0000"));
|
||||||
|
|
||||||
delete service;
|
delete service;
|
||||||
|
@ -2127,8 +2127,8 @@ void tst_QLowEnergyController::tst_customProgrammableDevice()
|
||||||
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
||||||
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
||||||
control->discoverServices();
|
control->discoverServices();
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
|
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.size() == 1, 20000);
|
||||||
QCOMPARE(stateSpy.count(), 2);
|
QCOMPARE(stateSpy.size(), 2);
|
||||||
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
QLowEnergyController::DiscoveringState);
|
QLowEnergyController::DiscoveringState);
|
||||||
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
|
@ -2160,7 +2160,7 @@ void tst_QLowEnergyController::tst_customProgrammableDevice()
|
||||||
service->readCharacteristic(encryptedChar);
|
service->readCharacteristic(encryptedChar);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!encryptedReadSpy.isEmpty(), 10000);
|
QTRY_VERIFY_WITH_TIMEOUT(!encryptedReadSpy.isEmpty(), 10000);
|
||||||
QVERIFY(encryptedErrorSpy.isEmpty());
|
QVERIFY(encryptedErrorSpy.isEmpty());
|
||||||
QCOMPARE(encryptedReadSpy.count(), 1);
|
QCOMPARE(encryptedReadSpy.size(), 1);
|
||||||
QList<QVariant> entry = encryptedReadSpy[0];
|
QList<QVariant> entry = encryptedReadSpy[0];
|
||||||
QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == encryptedChar);
|
QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == encryptedChar);
|
||||||
QCOMPARE(entry[1].toByteArray(), encryptedReference);
|
QCOMPARE(entry[1].toByteArray(), encryptedReference);
|
||||||
|
@ -2176,7 +2176,7 @@ void tst_QLowEnergyController::tst_customProgrammableDevice()
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!encryptedWriteSpy.isEmpty(), 10000);
|
QTRY_VERIFY_WITH_TIMEOUT(!encryptedWriteSpy.isEmpty(), 10000);
|
||||||
QVERIFY(encryptedErrorSpy.isEmpty());
|
QVERIFY(encryptedErrorSpy.isEmpty());
|
||||||
QVERIFY(encryptedReadSpy.isEmpty());
|
QVERIFY(encryptedReadSpy.isEmpty());
|
||||||
QCOMPARE(encryptedWriteSpy.count(), 1);
|
QCOMPARE(encryptedWriteSpy.size(), 1);
|
||||||
entry = encryptedWriteSpy[0];
|
entry = encryptedWriteSpy[0];
|
||||||
QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == encryptedChar);
|
QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == encryptedChar);
|
||||||
QCOMPARE(entry[1].toByteArray(), newValue);
|
QCOMPARE(entry[1].toByteArray(), newValue);
|
||||||
|
@ -2208,7 +2208,7 @@ void tst_QLowEnergyController::tst_customProgrammableDevice()
|
||||||
service->readCharacteristic(softwareRevChar);
|
service->readCharacteristic(softwareRevChar);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!readSpy.isEmpty(), 10000);
|
QTRY_VERIFY_WITH_TIMEOUT(!readSpy.isEmpty(), 10000);
|
||||||
QVERIFY(errorSpy.isEmpty());
|
QVERIFY(errorSpy.isEmpty());
|
||||||
QCOMPARE(readSpy.count(), 1);
|
QCOMPARE(readSpy.size(), 1);
|
||||||
entry = readSpy[0];
|
entry = readSpy[0];
|
||||||
QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == softwareRevChar);
|
QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == softwareRevChar);
|
||||||
QCOMPARE(entry[1].toByteArray(), expectedSoftRev);
|
QCOMPARE(entry[1].toByteArray(), expectedSoftRev);
|
||||||
|
@ -2233,7 +2233,7 @@ void tst_QLowEnergyController::tst_customProgrammableDevice()
|
||||||
service->readCharacteristic(manufacturerChar);
|
service->readCharacteristic(manufacturerChar);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!readSpy.isEmpty(), 10000);
|
QTRY_VERIFY_WITH_TIMEOUT(!readSpy.isEmpty(), 10000);
|
||||||
QVERIFY(errorSpy.isEmpty());
|
QVERIFY(errorSpy.isEmpty());
|
||||||
QCOMPARE(readSpy.count(), 1);
|
QCOMPARE(readSpy.size(), 1);
|
||||||
entry = readSpy[0];
|
entry = readSpy[0];
|
||||||
QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == manufacturerChar);
|
QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == manufacturerChar);
|
||||||
QCOMPARE(entry[1].toByteArray(), expectedManufacturer);
|
QCOMPARE(entry[1].toByteArray(), expectedManufacturer);
|
||||||
|
@ -2281,8 +2281,8 @@ void tst_QLowEnergyController::tst_errorCases()
|
||||||
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
||||||
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
||||||
control->discoverServices();
|
control->discoverServices();
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
|
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.size() == 1, 20000);
|
||||||
QCOMPARE(stateSpy.count(), 2);
|
QCOMPARE(stateSpy.size(), 2);
|
||||||
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
QLowEnergyController::DiscoveringState);
|
QLowEnergyController::DiscoveringState);
|
||||||
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
|
@ -2339,7 +2339,7 @@ void tst_QLowEnergyController::tst_errorCases()
|
||||||
// read invalid characteristic
|
// read invalid characteristic
|
||||||
irService->readCharacteristic(invalidChar);
|
irService->readCharacteristic(invalidChar);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
|
QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
|
||||||
QCOMPARE(irErrorSpy.count(), 1);
|
QCOMPARE(irErrorSpy.size(), 1);
|
||||||
QVERIFY(irWrittenSpy.isEmpty());
|
QVERIFY(irWrittenSpy.isEmpty());
|
||||||
QVERIFY(irReadSpy.isEmpty());
|
QVERIFY(irReadSpy.isEmpty());
|
||||||
QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
|
@ -2349,7 +2349,7 @@ void tst_QLowEnergyController::tst_errorCases()
|
||||||
// read invalid descriptor
|
// read invalid descriptor
|
||||||
irService->readDescriptor(invalidDesc);
|
irService->readDescriptor(invalidDesc);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
|
QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
|
||||||
QCOMPARE(irErrorSpy.count(), 1);
|
QCOMPARE(irErrorSpy.size(), 1);
|
||||||
QVERIFY(irDescWrittenSpy.isEmpty());
|
QVERIFY(irDescWrittenSpy.isEmpty());
|
||||||
QVERIFY(irDescReadSpy.isEmpty());
|
QVERIFY(irDescReadSpy.isEmpty());
|
||||||
QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
|
@ -2359,7 +2359,7 @@ void tst_QLowEnergyController::tst_errorCases()
|
||||||
// write invalid characteristic
|
// write invalid characteristic
|
||||||
irService->writeCharacteristic(invalidChar, QByteArray("foo"));
|
irService->writeCharacteristic(invalidChar, QByteArray("foo"));
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
|
QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
|
||||||
QCOMPARE(irErrorSpy.count(), 1);
|
QCOMPARE(irErrorSpy.size(), 1);
|
||||||
QVERIFY(irWrittenSpy.isEmpty());
|
QVERIFY(irWrittenSpy.isEmpty());
|
||||||
QVERIFY(irReadSpy.isEmpty());
|
QVERIFY(irReadSpy.isEmpty());
|
||||||
QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
|
@ -2369,7 +2369,7 @@ void tst_QLowEnergyController::tst_errorCases()
|
||||||
// write invalid descriptor
|
// write invalid descriptor
|
||||||
irService->readDescriptor(invalidDesc);
|
irService->readDescriptor(invalidDesc);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
|
QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
|
||||||
QCOMPARE(irErrorSpy.count(), 1);
|
QCOMPARE(irErrorSpy.size(), 1);
|
||||||
QVERIFY(irDescWrittenSpy.isEmpty());
|
QVERIFY(irDescWrittenSpy.isEmpty());
|
||||||
QVERIFY(irDescReadSpy.isEmpty());
|
QVERIFY(irDescReadSpy.isEmpty());
|
||||||
QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
|
@ -2383,7 +2383,7 @@ void tst_QLowEnergyController::tst_errorCases()
|
||||||
// read invalid characteristic
|
// read invalid characteristic
|
||||||
oadService->readCharacteristic(invalidChar);
|
oadService->readCharacteristic(invalidChar);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
|
QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
|
||||||
QCOMPARE(oadErrorSpy.count(), 1);
|
QCOMPARE(oadErrorSpy.size(), 1);
|
||||||
QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
QLowEnergyService::OperationError);
|
QLowEnergyService::OperationError);
|
||||||
oadErrorSpy.clear();
|
oadErrorSpy.clear();
|
||||||
|
@ -2391,7 +2391,7 @@ void tst_QLowEnergyController::tst_errorCases()
|
||||||
// read invalid descriptor
|
// read invalid descriptor
|
||||||
oadService->readDescriptor(invalidDesc);
|
oadService->readDescriptor(invalidDesc);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
|
QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
|
||||||
QCOMPARE(oadErrorSpy.count(), 1);
|
QCOMPARE(oadErrorSpy.size(), 1);
|
||||||
QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
QLowEnergyService::OperationError);
|
QLowEnergyService::OperationError);
|
||||||
oadErrorSpy.clear();
|
oadErrorSpy.clear();
|
||||||
|
@ -2399,7 +2399,7 @@ void tst_QLowEnergyController::tst_errorCases()
|
||||||
// write invalid characteristic
|
// write invalid characteristic
|
||||||
oadService->writeCharacteristic(invalidChar, QByteArray("foo"));
|
oadService->writeCharacteristic(invalidChar, QByteArray("foo"));
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
|
QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
|
||||||
QCOMPARE(oadErrorSpy.count(), 1);
|
QCOMPARE(oadErrorSpy.size(), 1);
|
||||||
QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
QLowEnergyService::OperationError);
|
QLowEnergyService::OperationError);
|
||||||
oadErrorSpy.clear();
|
oadErrorSpy.clear();
|
||||||
|
@ -2407,7 +2407,7 @@ void tst_QLowEnergyController::tst_errorCases()
|
||||||
// write invalid descriptor
|
// write invalid descriptor
|
||||||
oadService->readDescriptor(invalidDesc);
|
oadService->readDescriptor(invalidDesc);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
|
QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
|
||||||
QCOMPARE(oadErrorSpy.count(), 1);
|
QCOMPARE(oadErrorSpy.size(), 1);
|
||||||
QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
QLowEnergyService::OperationError);
|
QLowEnergyService::OperationError);
|
||||||
oadErrorSpy.clear();
|
oadErrorSpy.clear();
|
||||||
|
@ -2459,7 +2459,7 @@ void tst_QLowEnergyController::tst_errorCases()
|
||||||
QVERIFY(oadChar.isValid());
|
QVERIFY(oadChar.isValid());
|
||||||
oadService->readCharacteristic(oadChar);
|
oadService->readCharacteristic(oadChar);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
|
QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
|
||||||
QCOMPARE(oadErrorSpy.count(), 1);
|
QCOMPARE(oadErrorSpy.size(), 1);
|
||||||
QVERIFY(oadCharReadSpy.isEmpty());
|
QVERIFY(oadCharReadSpy.isEmpty());
|
||||||
QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
|
||||||
QLowEnergyService::CharacteristicReadError);
|
QLowEnergyService::CharacteristicReadError);
|
||||||
|
@ -2506,8 +2506,8 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
|
||||||
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
QSignalSpy discoveryFinishedSpy(control.data(), SIGNAL(discoveryFinished()));
|
||||||
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
|
||||||
control->discoverServices();
|
control->discoverServices();
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
|
QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.size() == 1, 20000);
|
||||||
QCOMPARE(stateSpy.count(), 2);
|
QCOMPARE(stateSpy.size(), 2);
|
||||||
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
QLowEnergyController::DiscoveringState);
|
QLowEnergyController::DiscoveringState);
|
||||||
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
|
||||||
|
@ -2594,7 +2594,7 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
|
||||||
QVERIFY(charReadSpy.isEmpty());
|
QVERIFY(charReadSpy.isEmpty());
|
||||||
service->readCharacteristic(imageIdentityChar);
|
service->readCharacteristic(imageIdentityChar);
|
||||||
QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000);
|
QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000);
|
||||||
QCOMPARE(errorSpy.count(), 1); // should throw CharacteristicReadError
|
QCOMPARE(errorSpy.size(), 1); // should throw CharacteristicReadError
|
||||||
QVERIFY(charReadSpy.isEmpty());
|
QVERIFY(charReadSpy.isEmpty());
|
||||||
entry = errorSpy[0];
|
entry = errorSpy[0];
|
||||||
QCOMPARE(entry[0].value<QLowEnergyService::ServiceError>(),
|
QCOMPARE(entry[0].value<QLowEnergyService::ServiceError>(),
|
||||||
|
@ -2607,8 +2607,8 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
|
||||||
// Write triggers a notification and write confirmation
|
// Write triggers a notification and write confirmation
|
||||||
service->writeCharacteristic(imageIdentityChar, QByteArray::fromHex("0"));
|
service->writeCharacteristic(imageIdentityChar, QByteArray::fromHex("0"));
|
||||||
QTest::qWait(1000);
|
QTest::qWait(1000);
|
||||||
QTRY_COMPARE_WITH_TIMEOUT(charChangedSpy.count(), 1, 5000);
|
QTRY_COMPARE_WITH_TIMEOUT(charChangedSpy.size(), 1, 5000);
|
||||||
QTRY_COMPARE_WITH_TIMEOUT(charWrittenSpy.count(), 1, 5000);
|
QTRY_COMPARE_WITH_TIMEOUT(charWrittenSpy.size(), 1, 5000);
|
||||||
|
|
||||||
// This is very SensorTag specific logic.
|
// This is very SensorTag specific logic.
|
||||||
// If the image block is empty the current firmware
|
// If the image block is empty the current firmware
|
||||||
|
@ -2643,8 +2643,8 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
|
||||||
// Image B
|
// Image B
|
||||||
service->writeCharacteristic(imageIdentityChar, QByteArray::fromHex("1"));
|
service->writeCharacteristic(imageIdentityChar, QByteArray::fromHex("1"));
|
||||||
QTest::qWait(1000);
|
QTest::qWait(1000);
|
||||||
QTRY_COMPARE_WITH_TIMEOUT(charChangedSpy.count(), 1, 5000);
|
QTRY_COMPARE_WITH_TIMEOUT(charChangedSpy.size(), 1, 5000);
|
||||||
QTRY_COMPARE_WITH_TIMEOUT(charWrittenSpy.count(), 1, 5000);;
|
QTRY_COMPARE_WITH_TIMEOUT(charWrittenSpy.size(), 1, 5000);;
|
||||||
|
|
||||||
entry = charChangedSpy[0];
|
entry = charChangedSpy[0];
|
||||||
first = entry[0].value<QLowEnergyCharacteristic>();
|
first = entry[0].value<QLowEnergyCharacteristic>();
|
||||||
|
@ -2689,8 +2689,8 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
|
||||||
// we only expect one signal (the notification but not the write confirmation)
|
// we only expect one signal (the notification but not the write confirmation)
|
||||||
// Wait at least a second for a potential second signals
|
// Wait at least a second for a potential second signals
|
||||||
QTest::qWait(1000);
|
QTest::qWait(1000);
|
||||||
QTRY_COMPARE_WITH_TIMEOUT(charChangedSpy.count(), 1, 10000);
|
QTRY_COMPARE_WITH_TIMEOUT(charChangedSpy.size(), 1, 10000);
|
||||||
QTRY_COMPARE_WITH_TIMEOUT(charWrittenSpy.count(), 0, 10000);
|
QTRY_COMPARE_WITH_TIMEOUT(charWrittenSpy.size(), 0, 10000);
|
||||||
|
|
||||||
entry = charChangedSpy[0];
|
entry = charChangedSpy[0];
|
||||||
first = entry[0].value<QLowEnergyCharacteristic>();
|
first = entry[0].value<QLowEnergyCharacteristic>();
|
||||||
|
@ -2725,8 +2725,8 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
|
||||||
// we only expect one signal (the notification but not the write confirmation)
|
// we only expect one signal (the notification but not the write confirmation)
|
||||||
// Wait at least a second for a potential second signals
|
// Wait at least a second for a potential second signals
|
||||||
QTest::qWait(1000);
|
QTest::qWait(1000);
|
||||||
QTRY_COMPARE_WITH_TIMEOUT(charWrittenSpy.count(), 0, 10000);
|
QTRY_COMPARE_WITH_TIMEOUT(charWrittenSpy.size(), 0, 10000);
|
||||||
QTRY_COMPARE_WITH_TIMEOUT(charChangedSpy.count(), 1, 10000);
|
QTRY_COMPARE_WITH_TIMEOUT(charChangedSpy.size(), 1, 10000);
|
||||||
|
|
||||||
entry = charChangedSpy[0];
|
entry = charChangedSpy[0];
|
||||||
first = entry[0].value<QLowEnergyCharacteristic>();
|
first = entry[0].value<QLowEnergyCharacteristic>();
|
||||||
|
|
|
@ -533,7 +533,7 @@ void tst_QNdefMessage::parseSingleRecordMessage()
|
||||||
QCOMPARE(textRecord.text(), parsedTextRecord.text());
|
QCOMPARE(textRecord.text(), parsedTextRecord.text());
|
||||||
QCOMPARE(textRecord.locale(), parsedTextRecord.locale());
|
QCOMPARE(textRecord.locale(), parsedTextRecord.locale());
|
||||||
|
|
||||||
if (expectedData.count() == 2) {
|
if (expectedData.size() == 2) {
|
||||||
QCOMPARE(parsedTextRecord.text(), expectedData.at(0).toString());
|
QCOMPARE(parsedTextRecord.text(), expectedData.at(0).toString());
|
||||||
QCOMPARE(parsedTextRecord.locale(), expectedData.at(1).toString());
|
QCOMPARE(parsedTextRecord.locale(), expectedData.at(1).toString());
|
||||||
}
|
}
|
||||||
|
@ -543,7 +543,7 @@ void tst_QNdefMessage::parseSingleRecordMessage()
|
||||||
|
|
||||||
QCOMPARE(uriRecord.uri(), parsedUriRecord.uri());
|
QCOMPARE(uriRecord.uri(), parsedUriRecord.uri());
|
||||||
|
|
||||||
if (expectedData.count() == 1)
|
if (expectedData.size() == 1)
|
||||||
QCOMPARE(parsedUriRecord.uri(), expectedData.at(0).toUrl());
|
QCOMPARE(parsedUriRecord.uri(), expectedData.at(0).toUrl());
|
||||||
} else if (record.isRecordType<QNdefRecord>()) {
|
} else if (record.isRecordType<QNdefRecord>()) {
|
||||||
QVERIFY(record.isEmpty());
|
QVERIFY(record.isEmpty());
|
||||||
|
|
|
@ -114,7 +114,7 @@ void tst_QNearFieldManager::userInformation()
|
||||||
const QString errorString("Failed to detect NFC targets");
|
const QString errorString("Failed to detect NFC targets");
|
||||||
manager.stopTargetDetection(errorString);
|
manager.stopTargetDetection(errorString);
|
||||||
|
|
||||||
QCOMPARE(spy.count(), 2);
|
QCOMPARE(spy.size(), 2);
|
||||||
QCOMPARE(spy.at(0).at(0).toString(), progressString);
|
QCOMPARE(spy.at(0).at(0).toString(), progressString);
|
||||||
QCOMPARE(spy.at(1).at(0).toString(), errorString);
|
QCOMPARE(spy.at(1).at(0).toString(), errorString);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ void tst_QNearFieldManager::targetDetected()
|
||||||
|
|
||||||
manager.stopTargetDetection();
|
manager.stopTargetDetection();
|
||||||
|
|
||||||
QCOMPARE(detectionStoppedSpy.count(), 1);
|
QCOMPARE(detectionStoppedSpy.size(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QNearFieldManager)
|
QTEST_MAIN(tst_QNearFieldManager)
|
||||||
|
|
|
@ -368,7 +368,7 @@ void BtLocalDevice::dumpServiceDiscovery()
|
||||||
qDebug() << "Device Discovery active:" << deviceAgent->isActive();
|
qDebug() << "Device Discovery active:" << deviceAgent->isActive();
|
||||||
qDebug() << "Error:" << deviceAgent->error() << deviceAgent->errorString();
|
qDebug() << "Error:" << deviceAgent->error() << deviceAgent->errorString();
|
||||||
const QList<QBluetoothDeviceInfo> list = deviceAgent->discoveredDevices();
|
const QList<QBluetoothDeviceInfo> list = deviceAgent->discoveredDevices();
|
||||||
qDebug() << "Discovered Devices:" << list.count();
|
qDebug() << "Discovered Devices:" << list.size();
|
||||||
|
|
||||||
for (const QBluetoothDeviceInfo &info : list)
|
for (const QBluetoothDeviceInfo &info : list)
|
||||||
qDebug() << info.name() << info.address().toString() << info.rssi();
|
qDebug() << info.name() << info.address().toString() << info.rssi();
|
||||||
|
@ -377,7 +377,7 @@ void BtLocalDevice::dumpServiceDiscovery()
|
||||||
qDebug() << "Service Discovery active:" << serviceAgent->isActive();
|
qDebug() << "Service Discovery active:" << serviceAgent->isActive();
|
||||||
qDebug() << "Error:" << serviceAgent->error() << serviceAgent->errorString();
|
qDebug() << "Error:" << serviceAgent->error() << serviceAgent->errorString();
|
||||||
const QList<QBluetoothServiceInfo> list = serviceAgent->discoveredServices();
|
const QList<QBluetoothServiceInfo> list = serviceAgent->discoveredServices();
|
||||||
qDebug() << "Discovered Services:" << list.count();
|
qDebug() << "Discovered Services:" << list.size();
|
||||||
|
|
||||||
for (const QBluetoothServiceInfo &i : list) {
|
for (const QBluetoothServiceInfo &i : list) {
|
||||||
qDebug() << i.device().address().toString() << i.device().name() << i.serviceName();
|
qDebug() << i.device().address().toString() << i.device().name() << i.serviceName();
|
||||||
|
@ -748,7 +748,7 @@ void BtLocalDevice::dumpInformation()
|
||||||
qDebug() << "###### default local device";
|
qDebug() << "###### default local device";
|
||||||
dumpLocalDevice(localDevice);
|
dumpLocalDevice(localDevice);
|
||||||
const QList<QBluetoothHostInfo> list = QBluetoothLocalDevice::allDevices();
|
const QList<QBluetoothHostInfo> list = QBluetoothLocalDevice::allDevices();
|
||||||
qDebug() << "Found local devices: " << list.count();
|
qDebug() << "Found local devices: " << list.size();
|
||||||
for (const QBluetoothHostInfo &info : list) {
|
for (const QBluetoothHostInfo &info : list) {
|
||||||
qDebug() << " " << info.address().toString() << " " <<info.name();
|
qDebug() << " " << info.address().toString() << " " <<info.name();
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,8 +331,8 @@ void tst_qlowenergycontroller_device::readWriteLargeCharacteristic()
|
||||||
|
|
||||||
QSignalSpy readSpy(service.get(), &QLowEnergyService::characteristicRead);
|
QSignalSpy readSpy(service.get(), &QLowEnergyService::characteristicRead);
|
||||||
QSignalSpy writtenSpy(service.get(), &QLowEnergyService::characteristicWritten);
|
QSignalSpy writtenSpy(service.get(), &QLowEnergyService::characteristicWritten);
|
||||||
QCOMPARE(readSpy.count(), 0);
|
QCOMPARE(readSpy.size(), 0);
|
||||||
QCOMPARE(writtenSpy.count(), 0);
|
QCOMPARE(writtenSpy.size(), 0);
|
||||||
|
|
||||||
// The service discovery skipped the values => check that the default value is all zeroes
|
// The service discovery skipped the values => check that the default value is all zeroes
|
||||||
auto characteristic = service->characteristic(QBluetoothUuid(largeCharacteristicCharUuid));
|
auto characteristic = service->characteristic(QBluetoothUuid(largeCharacteristicCharUuid));
|
||||||
|
@ -342,7 +342,7 @@ void tst_qlowenergycontroller_device::readWriteLargeCharacteristic()
|
||||||
|
|
||||||
// Read the characteristic value and verify it is the one the server-side sets (0x0b 0x00 ..)
|
// Read the characteristic value and verify it is the one the server-side sets (0x0b 0x00 ..)
|
||||||
service->readCharacteristic(characteristic);
|
service->readCharacteristic(characteristic);
|
||||||
QTRY_COMPARE(readSpy.count(), 1);
|
QTRY_COMPARE(readSpy.size(), 1);
|
||||||
qDebug() << "Large characteristic value after read:" << characteristic.value();
|
qDebug() << "Large characteristic value after read:" << characteristic.value();
|
||||||
testArray = QByteArray(512, 0);
|
testArray = QByteArray(512, 0);
|
||||||
testArray[0] = 0x0b;
|
testArray[0] = 0x0b;
|
||||||
|
@ -354,10 +354,10 @@ void tst_qlowenergycontroller_device::readWriteLargeCharacteristic()
|
||||||
}
|
}
|
||||||
service->writeCharacteristic(characteristic, testArray);
|
service->writeCharacteristic(characteristic, testArray);
|
||||||
QCOMPARE(service->error(), QLowEnergyService::ServiceError::NoError);
|
QCOMPARE(service->error(), QLowEnergyService::ServiceError::NoError);
|
||||||
QTRY_COMPARE(writtenSpy.count(), 1);
|
QTRY_COMPARE(writtenSpy.size(), 1);
|
||||||
|
|
||||||
service->readCharacteristic(characteristic);
|
service->readCharacteristic(characteristic);
|
||||||
QTRY_COMPARE(readSpy.count(), 2);
|
QTRY_COMPARE(readSpy.size(), 2);
|
||||||
qDebug() << "Large characteristic value after write/read:" << characteristic.value();
|
qDebug() << "Large characteristic value after write/read:" << characteristic.value();
|
||||||
QCOMPARE(characteristic.value(), testArray);
|
QCOMPARE(characteristic.value(), testArray);
|
||||||
}
|
}
|
||||||
|
@ -378,8 +378,8 @@ void tst_qlowenergycontroller_device::readDuringServiceDiscovery()
|
||||||
|
|
||||||
QSignalSpy readSpy(service.get(), &QLowEnergyService::characteristicRead);
|
QSignalSpy readSpy(service.get(), &QLowEnergyService::characteristicRead);
|
||||||
QSignalSpy writtenSpy(service.get(), &QLowEnergyService::characteristicWritten);
|
QSignalSpy writtenSpy(service.get(), &QLowEnergyService::characteristicWritten);
|
||||||
QCOMPARE(readSpy.count(), 0);
|
QCOMPARE(readSpy.size(), 0);
|
||||||
QCOMPARE(writtenSpy.count(), 0);
|
QCOMPARE(writtenSpy.size(), 0);
|
||||||
|
|
||||||
// Value that is initially set on the characteristic at the server-side (0x0b 0x00 ..)
|
// Value that is initially set on the characteristic at the server-side (0x0b 0x00 ..)
|
||||||
QByteArray testArray(512, 0);
|
QByteArray testArray(512, 0);
|
||||||
|
@ -396,7 +396,7 @@ void tst_qlowenergycontroller_device::readDuringServiceDiscovery()
|
||||||
|
|
||||||
// Check that the value from service discovery and explicit characteristic read match
|
// Check that the value from service discovery and explicit characteristic read match
|
||||||
service->readCharacteristic(characteristic);
|
service->readCharacteristic(characteristic);
|
||||||
QTRY_COMPARE(readSpy.count(), 1);
|
QTRY_COMPARE(readSpy.size(), 1);
|
||||||
qDebug() << "Large characteristic value after read:" << characteristic.value();
|
qDebug() << "Large characteristic value after read:" << characteristic.value();
|
||||||
QCOMPARE(characteristic.value(), valueFromServiceDiscovery);
|
QCOMPARE(characteristic.value(), valueFromServiceDiscovery);
|
||||||
|
|
||||||
|
@ -406,10 +406,10 @@ void tst_qlowenergycontroller_device::readDuringServiceDiscovery()
|
||||||
}
|
}
|
||||||
service->writeCharacteristic(characteristic, testArray);
|
service->writeCharacteristic(characteristic, testArray);
|
||||||
QCOMPARE(service->error(), QLowEnergyService::ServiceError::NoError);
|
QCOMPARE(service->error(), QLowEnergyService::ServiceError::NoError);
|
||||||
QTRY_COMPARE(writtenSpy.count(), 1);
|
QTRY_COMPARE(writtenSpy.size(), 1);
|
||||||
|
|
||||||
service->readCharacteristic(characteristic);
|
service->readCharacteristic(characteristic);
|
||||||
QTRY_COMPARE(readSpy.count(), 2);
|
QTRY_COMPARE(readSpy.size(), 2);
|
||||||
qDebug() << "Large characteristic value after write/read:" << characteristic.value();
|
qDebug() << "Large characteristic value after write/read:" << characteristic.value();
|
||||||
QCOMPARE(characteristic.value(), testArray);
|
QCOMPARE(characteristic.value(), testArray);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue