summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycontroller_winrt_new.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2019-04-03 13:34:20 +0200
committerOliver Wolff <oliver.wolff@qt.io>2019-04-15 12:24:15 +0000
commit25d556c2097445d16cc05b3961f86f1b6ae60ed1 (patch)
tree05e3141d8cff0bf688e22b8b797eb6fedc14ef8c /src/bluetooth/qlowenergycontroller_winrt_new.cpp
parent1bf25e130d4d6ae859c4f2aabe2a752532aee5e5 (diff)
winrt: Move byteArrayFromBuffer into qbluetoothutils_winrt
That code has been (unneededly) duplicated several times. We should have that helper function just once. Change-Id: I28fc9c5f7f7218b7870dc30bec228c9af8c6b090 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_winrt_new.cpp')
-rw-r--r--src/bluetooth/qlowenergycontroller_winrt_new.cpp32
1 files changed, 1 insertions, 31 deletions
diff --git a/src/bluetooth/qlowenergycontroller_winrt_new.cpp b/src/bluetooth/qlowenergycontroller_winrt_new.cpp
index 5501c4f3..45a80252 100644
--- a/src/bluetooth/qlowenergycontroller_winrt_new.cpp
+++ b/src/bluetooth/qlowenergycontroller_winrt_new.cpp
@@ -39,6 +39,7 @@
#include "qlowenergycontroller_winrt_new_p.h"
#include "qlowenergycontroller_winrt_p.h"
+#include "qbluetoothutils_winrt_p.h"
#include <QtBluetooth/QLowEnergyCharacteristicData>
#include <QtBluetooth/QLowEnergyDescriptorData>
@@ -119,37 +120,6 @@ QLowEnergyControllerPrivate *createWinRTLowEnergyController()
return new QLowEnergyControllerPrivateWinRT();
}
-static QByteArray byteArrayFromBuffer(const ComPtr<IBuffer> &buffer, bool isWCharString = false)
-{
- if (!buffer) {
- qCWarning(QT_BT_WINRT) << "nullptr passed to byteArrayFromBuffer";
- return QByteArray();
- }
- ComPtr<Windows::Storage::Streams::IBufferByteAccess> byteAccess;
- HRESULT hr = buffer.As(&byteAccess);
- if (FAILED(hr)) {
- qCWarning(QT_BT_WINRT) << "Could not cast Buffer to ByteAccess";
- return QByteArray();
- }
- char *data;
- hr = byteAccess->Buffer(reinterpret_cast<byte **>(&data));
- if (FAILED(hr)) {
- qCWarning(QT_BT_WINRT) << "Could not obtain buffer data";
- return QByteArray();
- }
- UINT32 size;
- hr = buffer->get_Length(&size);
- if (FAILED(hr)) {
- qCWarning(QT_BT_WINRT) << "Could not obtain buffer length";
- return QByteArray();
- }
- if (isWCharString) {
- QString valueString = QString::fromUtf16(reinterpret_cast<ushort *>(data)).left(size / 2);
- return valueString.toUtf8();
- }
- return QByteArray(data, int(size));
-}
-
static QByteArray byteArrayFromGattResult(const ComPtr<IGattReadResult> &gattResult,
bool isWCharString = false)
{