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:
Dirk Hohndel 2017-09-20 19:19:25 -04:00
parent 16d9b0c790
commit bb1df1218d

View file

@ -151,9 +151,12 @@ 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;
@ -168,9 +171,6 @@ dc_status_t BLEObject::write(const void *data, size_t size, size_t *actual)
return DC_STATUS_SUCCESS;
}
return DC_STATUS_IO;
}
dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)
{
if (actual)