summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycontroller_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_win.cpp')
-rw-r--r--src/bluetooth/qlowenergycontroller_win.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/bluetooth/qlowenergycontroller_win.cpp b/src/bluetooth/qlowenergycontroller_win.cpp
index b05d20e6..9f10a167 100644
--- a/src/bluetooth/qlowenergycontroller_win.cpp
+++ b/src/bluetooth/qlowenergycontroller_win.cpp
@@ -321,19 +321,22 @@ static QByteArray getGattCharacteristicValue(
QByteArray valueBuffer;
USHORT valueBufferSize = 0;
for (;;) {
+ const auto valuePtr = valueBuffer.isEmpty()
+ ? NULL
+ : reinterpret_cast<PBTH_LE_GATT_CHARACTERISTIC_VALUE>(valueBuffer.data());
+
const HRESULT hr = ::BluetoothGATTGetCharacteristicValue(
hService,
gattCharacteristic,
valueBufferSize,
- valueBuffer.isEmpty() ? NULL : reinterpret_cast<PBTH_LE_GATT_CHARACTERISTIC_VALUE>(valueBuffer.data()),
+ valuePtr,
&valueBufferSize,
BLUETOOTH_GATT_FLAG_NONE);
if (SUCCEEDED(hr)) {
*systemErrorCode = NO_ERROR;
- const PBTH_LE_GATT_CHARACTERISTIC_VALUE value = reinterpret_cast<
- PBTH_LE_GATT_CHARACTERISTIC_VALUE>(valueBuffer.data());
- return QByteArray(reinterpret_cast<const char *>(&value->Data[0]), value->DataSize);
+ return QByteArray(reinterpret_cast<const char *>(&valuePtr->Data[0]),
+ valuePtr->DataSize);
} else {
const DWORD error = WIN32_FROM_HRESULT(hr);
if (error == ERROR_MORE_DATA) {
@@ -421,20 +424,22 @@ static QByteArray getGattDescriptorValue(
QByteArray valueBuffer;
USHORT valueBufferSize = 0;
for (;;) {
+ const auto valuePtr = valueBuffer.isEmpty()
+ ? NULL
+ : reinterpret_cast<PBTH_LE_GATT_DESCRIPTOR_VALUE>(valueBuffer.data());
+
const HRESULT hr = ::BluetoothGATTGetDescriptorValue(
hService,
gattDescriptor,
valueBufferSize,
- valueBuffer.isEmpty() ? NULL : reinterpret_cast<PBTH_LE_GATT_DESCRIPTOR_VALUE>(valueBuffer.data()),
+ valuePtr,
&valueBufferSize,
BLUETOOTH_GATT_FLAG_NONE);
if (SUCCEEDED(hr)) {
*systemErrorCode = NO_ERROR;
- const PBTH_LE_GATT_DESCRIPTOR_VALUE value = reinterpret_cast<
- PBTH_LE_GATT_DESCRIPTOR_VALUE>(valueBuffer.data());
-
- return QByteArray(reinterpret_cast<const char *>(&value->Data[0]), value->DataSize);
+ return QByteArray(reinterpret_cast<const char *>(&valuePtr->Data[0]),
+ valuePtr->DataSize);
} else {
const DWORD error = WIN32_FROM_HRESULT(hr);
if (error == ERROR_MORE_DATA) {