summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-07-21 14:03:19 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-07-23 15:28:47 +0200
commit58d1b5bdffc25f4ff22dcd00f0572c9c4fac3f88 (patch)
treed7f5302fb9a303cf67d9d6899106b65a7d2e7962 /src
parentf1b1896889dd32d4e304e369844c9764ec49364d (diff)
downloadqtconnectivity-58d1b5bdffc25f4ff22dcd00f0572c9c4fac3f88.tar.gz
Characteristic and descriptor value() are no longer hex encoded
There is no point converting the data to its hex representation. The use case at hand will decide it in the current application context. The returned QByteArray is the raw byte array as it comes from the device. This behavior was legacy (introduced by the previous API) and subsequently it was simply adopted. Change-Id: If662c02a5e3c3d37cccb374add02e75522352894 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth/qlowenergycharacteristic.cpp4
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp23
2 files changed, 11 insertions, 16 deletions
diff --git a/src/bluetooth/qlowenergycharacteristic.cpp b/src/bluetooth/qlowenergycharacteristic.cpp
index bba5b7a0..0c3dc7af 100644
--- a/src/bluetooth/qlowenergycharacteristic.cpp
+++ b/src/bluetooth/qlowenergycharacteristic.cpp
@@ -161,9 +161,7 @@ QLowEnergyCharacteristic::PropertyTypes QLowEnergyCharacteristic::properties() c
}
/*!
- Returns value of the gatt characteristic.
-
- The returned QByteArray contains the hex representation of the value.
+ Returns value of the GATT characteristic.
*/
QByteArray QLowEnergyCharacteristic::value() const
{
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp
index f95e6a62..d3c7e024 100644
--- a/src/bluetooth/qlowenergycontroller_bluez.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluez.cpp
@@ -521,10 +521,10 @@ void QLowEnergyControllerPrivate::processReply(
// we ignore error response
if (!isErrorResponse) {
if (!descriptorHandle)
- updateValueOfCharacteristic(charHandle, response.mid(1).toHex());
+ updateValueOfCharacteristic(charHandle, response.mid(1));
else
updateValueOfDescriptor(charHandle, descriptorHandle,
- response.mid(1).toHex());
+ response.mid(1));
}
if (request.reference2.toBool()) {
@@ -881,9 +881,8 @@ void QLowEnergyControllerPrivate::processUnsolicitedReply(const QByteArray &payl
const QLowEnergyCharacteristic ch = characteristicForHandle(changedHandle);
if (ch.isValid() && ch.handle() == changedHandle) {
- const QByteArray newValue = payload.mid(3).toHex();
- updateValueOfCharacteristic(ch.attributeHandle(), newValue);
- emit ch.d_ptr->characteristicChanged(ch, newValue);
+ updateValueOfCharacteristic(ch.attributeHandle(), payload.mid(3));
+ emit ch.d_ptr->characteristicChanged(ch, payload.mid(3));
} else {
qCWarning(QT_BT_BLUEZ) << "Cannot find matching characteristic for "
"notification/indication";
@@ -957,9 +956,8 @@ void QLowEnergyControllerPrivate::writeCharacteristic(
return;
const QLowEnergyHandle valueHandle = service->characteristicList[charHandle].valueHandle;
- const QByteArray rawData = QByteArray::fromHex(newValue);
- // sizeof(command) + sizeof(handle) + sizeof(rawData)
- const int size = 1 + 2 + rawData.size();
+ // sizeof(command) + sizeof(handle) + sizeof(newValue)
+ const int size = 1 + 2 + newValue.size();
quint8 packet[WRITE_REQUEST_SIZE];
packet[0] = ATT_OP_WRITE_REQUEST;
@@ -968,7 +966,7 @@ void QLowEnergyControllerPrivate::writeCharacteristic(
QByteArray data(size, Qt::Uninitialized);
memcpy(data.data(), packet, WRITE_REQUEST_SIZE);
- memcpy(&(data.data()[WRITE_REQUEST_SIZE]), rawData.constData(), rawData.size());
+ memcpy(&(data.data()[WRITE_REQUEST_SIZE]), newValue.constData(), newValue.size());
qCDebug(QT_BT_BLUEZ) << "Writing characteristic" << hex << charHandle
<< "(size:" << size << ")";
@@ -991,9 +989,8 @@ void QLowEnergyControllerPrivate::writeDescriptor(
{
Q_ASSERT(!service.isNull());
- const QByteArray rawData = QByteArray::fromHex(newValue);
- // sizeof(command) + sizeof(handle) + sizeof(rawData)
- const int size = 1 + 2 + rawData.size();
+ // sizeof(command) + sizeof(handle) + sizeof(newValue)
+ const int size = 1 + 2 + newValue.size();
quint8 packet[WRITE_REQUEST_SIZE];
packet[0] = ATT_OP_WRITE_REQUEST;
@@ -1001,7 +998,7 @@ void QLowEnergyControllerPrivate::writeDescriptor(
QByteArray data(size, Qt::Uninitialized);
memcpy(data.data(), packet, WRITE_REQUEST_SIZE);
- memcpy(&(data.data()[WRITE_REQUEST_SIZE]), rawData.constData(), rawData.size());
+ memcpy(&(data.data()[WRITE_REQUEST_SIZE]), newValue.constData(), newValue.size());
qCDebug(QT_BT_BLUEZ) << "Writing descriptor" << hex << descriptorHandle
<< "(size:" << size << ")";