diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-07-21 14:03:19 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-07-23 15:28:47 +0200 |
commit | 58d1b5bdffc25f4ff22dcd00f0572c9c4fac3f88 (patch) | |
tree | d7f5302fb9a303cf67d9d6899106b65a7d2e7962 /examples | |
parent | f1b1896889dd32d4e304e369844c9764ec49364d (diff) |
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 'examples')
-rw-r--r-- | examples/bluetooth/heartlistener/heartrate.cpp | 6 | ||||
-rw-r--r-- | examples/bluetooth/lowenergyscanner/characteristicinfo.cpp | 9 |
2 files changed, 7 insertions, 8 deletions
diff --git a/examples/bluetooth/heartlistener/heartrate.cpp b/examples/bluetooth/heartlistener/heartrate.cpp index 7ada09dd..ac61a076 100644 --- a/examples/bluetooth/heartlistener/heartrate.cpp +++ b/examples/bluetooth/heartlistener/heartrate.cpp @@ -223,7 +223,7 @@ void HeartRate::disconnectService() //disable notifications if (m_notificationDesc.isValid() && m_service) { - m_service->writeDescriptor(m_notificationDesc, QByteArray("0000")); + m_service->writeDescriptor(m_notificationDesc, QByteArray::fromHex("0000")); } else { m_control->disconnectFromDevice(); delete m_service; @@ -255,7 +255,7 @@ void HeartRate::serviceStateChanged(QLowEnergyService::ServiceState s) const QLowEnergyDescriptor m_notificationDesc = hrChar.descriptor( QBluetoothUuid::ClientCharacteristicConfiguration); if (m_notificationDesc.isValid()) { - m_service->writeDescriptor(m_notificationDesc, QByteArray("0100")); + m_service->writeDescriptor(m_notificationDesc, QByteArray::fromHex("0100")); setMessage("Measuring"); m_start = QDateTime::currentDateTime(); } @@ -287,7 +287,7 @@ void HeartRate::updateHeartRateValue(const QLowEnergyCharacteristic &c, return; //! [Reading value] - const char *data = QByteArray::fromHex(value).constData(); + const char *data = value.constData(); quint8 flags = data[0]; //Heart Rate diff --git a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp index 29e97f56..d7ae8438 100644 --- a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp +++ b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp @@ -67,7 +67,7 @@ QString CharacteristicInfo::getName() const // find descriptor with CharacteristicUserDescription foreach (const QLowEnergyDescriptor &descriptor, m_characteristic.descriptors()) { if (descriptor.type() == QBluetoothUuid::CharacteristicUserDescription) { - name = QByteArray::fromHex(descriptor.value()); + name = descriptor.value(); break; } } @@ -95,8 +95,7 @@ QString CharacteristicInfo::getUuid() const QString CharacteristicInfo::getValue() const { - // All characteristics values are in hexadecimal format. - // Show human string first and hex value below + // Show raw string first and hex value below QByteArray a = m_characteristic.value(); QString result; if (a.isEmpty()) { @@ -104,9 +103,9 @@ QString CharacteristicInfo::getValue() const return result; } - result = QByteArray::fromHex(a); + result = a; result += QLatin1Char('\n'); - result += a; + result += a.toHex(); return result; } |