summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/bluetooth/heartlistener/heartrate.cpp6
-rw-r--r--examples/bluetooth/lowenergyscanner/characteristicinfo.cpp9
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;
}