From dc75ca260e79b01cb5dcbf6682660c948a2935a3 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 19 Feb 2014 15:39:42 +0100 Subject: Show characteristic values with proper encoding in LEscanner example Change-Id: I7f5fceae5d47e62d9b26fbced0cf73abe8d18d23 Reviewed-by: Nedim Hadzic Reviewed-by: Alex Blasche --- examples/bluetooth/lowenergyscanner/assets/Characteristics.qml | 1 + examples/bluetooth/lowenergyscanner/characteristicinfo.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml b/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml index 6420e893..bb308f2f 100644 --- a/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml +++ b/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml @@ -89,6 +89,7 @@ Rectangle { id: characteristicValue textContent: ("Value: " + modelData.characteristicValue) anchors.bottom: characteristicHandle.top + horizontalAlignment: Text.AlignHCenter anchors.topMargin: 5 } diff --git a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp index 1d6bfa21..18b9e282 100644 --- a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp +++ b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp @@ -72,11 +72,12 @@ QString CharacteristicInfo::getUuid() const QString CharacteristicInfo::getValue() const { // All characteristics values are in hexadecimal format. - QString hexvalue = ""; + // Show human string first and hex value below QByteArray a = m_characteristic.value(); - for (int i = 0; i < a.size(); i++){ - hexvalue.append(a.at(i));} - return hexvalue; + QString result; + result += QByteArray::fromHex(a) + QLatin1Char('\n'); + result += a; + return result; } QString CharacteristicInfo::getHandle() const -- cgit v1.2.3