summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/lowenergyscanner
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-02-19 15:39:42 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-20 21:37:53 +0100
commitdc75ca260e79b01cb5dcbf6682660c948a2935a3 (patch)
tree2539e74d058e00a21ec499c47bbbad4df9846702 /examples/bluetooth/lowenergyscanner
parentd772307dab9e2a3ef99d924d23af8688bff592db (diff)
Show characteristic values with proper encoding in LEscanner example
Change-Id: I7f5fceae5d47e62d9b26fbced0cf73abe8d18d23 Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'examples/bluetooth/lowenergyscanner')
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Characteristics.qml1
-rw-r--r--examples/bluetooth/lowenergyscanner/characteristicinfo.cpp9
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