summaryrefslogtreecommitdiffstats
path: root/core/qt-ble.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-09-20 19:19:25 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-09-20 19:19:25 -0400
commitbb1df1218d83aaa2bcb503e53246e19ab2e29c62 (patch)
tree69619577812fc5cccd7d0b3f538c195c431fbdc5 /core/qt-ble.cpp
parent16d9b0c790c1fb0dae6e001a3107fb4f82356e90 (diff)
downloadsubsurface-bb1df1218d83aaa2bcb503e53246e19ab2e29c62.tar.gz
BLE support: simplify write function
It seems clearer to bail when list is empty... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/qt-ble.cpp')
-rw-r--r--core/qt-ble.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp
index 01597d4b8..a72736d4f 100644
--- a/core/qt-ble.cpp
+++ b/core/qt-ble.cpp
@@ -151,24 +151,24 @@ dc_status_t BLEObject::write(const void *data, size_t size, size_t *actual)
}
QList<QLowEnergyCharacteristic> list = preferredService()->characteristics();
+
+ if (list.isEmpty())
+ return DC_STATUS_IO;
+
QByteArray bytes((const char *)data, (int) size);
- if (!list.isEmpty()) {
- const QLowEnergyCharacteristic &c = list.constFirst();
- QLowEnergyService::WriteMode mode;
+ const QLowEnergyCharacteristic &c = list.constFirst();
+ QLowEnergyService::WriteMode mode;
- mode = (c.properties() & QLowEnergyCharacteristic::WriteNoResponse) ?
+ mode = (c.properties() & QLowEnergyCharacteristic::WriteNoResponse) ?
QLowEnergyService::WriteWithoutResponse :
QLowEnergyService::WriteWithResponse;
- if (IS_SHEARWATER(device))
- bytes.prepend("\1\0", 2);
-
- preferredService()->writeCharacteristic(c, bytes, mode);
- return DC_STATUS_SUCCESS;
- }
+ if (IS_SHEARWATER(device))
+ bytes.prepend("\1\0", 2);
- return DC_STATUS_IO;
+ preferredService()->writeCharacteristic(c, bytes, mode);
+ return DC_STATUS_SUCCESS;
}
dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)