mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 18:23:23 +00:00
BLE support: simplify write function
It seems clearer to bail when list is empty... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
16d9b0c790
commit
bb1df1218d
1 changed files with 11 additions and 11 deletions
|
@ -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);
|
||||
if (IS_SHEARWATER(device))
|
||||
bytes.prepend("\1\0", 2);
|
||||
|
||||
preferredService()->writeCharacteristic(c, bytes, mode);
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue