mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
BLE code: address some compiler warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
fbdba88dec
commit
f98fa50c39
2 changed files with 21 additions and 6 deletions
|
@ -37,6 +37,8 @@ void waitFor(int ms) {
|
||||||
|
|
||||||
void BLEObject::serviceStateChanged(QLowEnergyService::ServiceState s)
|
void BLEObject::serviceStateChanged(QLowEnergyService::ServiceState s)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(s)
|
||||||
|
|
||||||
QList<QLowEnergyCharacteristic> list;
|
QList<QLowEnergyCharacteristic> list;
|
||||||
|
|
||||||
auto service = qobject_cast<QLowEnergyService*>(sender());
|
auto service = qobject_cast<QLowEnergyService*>(sender());
|
||||||
|
@ -50,12 +52,17 @@ void BLEObject::serviceStateChanged(QLowEnergyService::ServiceState s)
|
||||||
|
|
||||||
void BLEObject::characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value)
|
void BLEObject::characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(c)
|
||||||
|
|
||||||
receivedPackets.append(value);
|
receivedPackets.append(value);
|
||||||
waitForPacket.exit();
|
waitForPacket.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLEObject::writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &value)
|
void BLEObject::writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &value)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(d)
|
||||||
|
Q_UNUSED(value)
|
||||||
|
|
||||||
qDebug() << "BLE write completed";
|
qDebug() << "BLE write completed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +106,8 @@ static int device_is_shearwater(dc_user_device_t *device)
|
||||||
|
|
||||||
dc_status_t BLEObject::write(const void *data, size_t size, size_t *actual)
|
dc_status_t BLEObject::write(const void *data, size_t size, size_t *actual)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(actual) // that seems like it might cause problems
|
||||||
|
|
||||||
QList<QLowEnergyCharacteristic> list = preferredService()->characteristics();
|
QList<QLowEnergyCharacteristic> list = preferredService()->characteristics();
|
||||||
QByteArray bytes((const char *)data, (int) size);
|
QByteArray bytes((const char *)data, (int) size);
|
||||||
|
|
||||||
|
@ -127,8 +136,6 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)
|
||||||
if (list.isEmpty())
|
if (list.isEmpty())
|
||||||
return DC_STATUS_IO;
|
return DC_STATUS_IO;
|
||||||
|
|
||||||
const QLowEnergyCharacteristic &c = list.constLast();
|
|
||||||
|
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
int msec = 5000;
|
int msec = 5000;
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
|
@ -147,7 +154,7 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)
|
||||||
if (device_is_shearwater(device))
|
if (device_is_shearwater(device))
|
||||||
packet.remove(0,2);
|
packet.remove(0,2);
|
||||||
|
|
||||||
if (size > packet.size())
|
if (size > (size_t)packet.size())
|
||||||
size = packet.size();
|
size = packet.size();
|
||||||
memcpy(data, packet.data(), size);
|
memcpy(data, packet.data(), size);
|
||||||
*actual = size;
|
*actual = size;
|
||||||
|
@ -156,6 +163,7 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)
|
||||||
|
|
||||||
dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *devaddr)
|
dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *devaddr)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(context)
|
||||||
/*
|
/*
|
||||||
* LE-only devices get the "LE:" prepended by the scanning
|
* LE-only devices get the "LE:" prepended by the scanning
|
||||||
* code, so that the rfcomm code can see they only do LE.
|
* code, so that the rfcomm code can see they only do LE.
|
||||||
|
|
|
@ -106,7 +106,7 @@ static dc_status_t ble_serial_flush_write(void)
|
||||||
if (!bytes)
|
if (!bytes)
|
||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
buffer.out_bytes = 0;
|
buffer.out_bytes = 0;
|
||||||
ble_serial_ops.packet_write(&ble_serial_ops, buffer.out, bytes, NULL);
|
return ble_serial_ops.packet_write(&ble_serial_ops, buffer.out, bytes, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static dc_status_t ble_serial_flush_read(void)
|
static dc_status_t ble_serial_flush_read(void)
|
||||||
|
@ -124,7 +124,8 @@ static dc_status_t ble_serial_close(dc_custom_io_t *io)
|
||||||
|
|
||||||
static dc_status_t ble_serial_read(dc_custom_io_t *io, void* data, size_t size, size_t *actual)
|
static dc_status_t ble_serial_read(dc_custom_io_t *io, void* data, size_t size, size_t *actual)
|
||||||
{
|
{
|
||||||
int len;
|
Q_UNUSED(io)
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (buffer.in_pos >= buffer.in_bytes) {
|
if (buffer.in_pos >= buffer.in_bytes) {
|
||||||
dc_status_t rc;
|
dc_status_t rc;
|
||||||
|
@ -153,12 +154,13 @@ static dc_status_t ble_serial_read(dc_custom_io_t *io, void* data, size_t size,
|
||||||
|
|
||||||
static dc_status_t ble_serial_write(dc_custom_io_t *io, const void* data, size_t size, size_t *actual)
|
static dc_status_t ble_serial_write(dc_custom_io_t *io, const void* data, size_t size, size_t *actual)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(io)
|
||||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||||
size_t transferred = 0;
|
size_t transferred = 0;
|
||||||
|
|
||||||
ble_serial_flush_read();
|
ble_serial_flush_read();
|
||||||
while (size) {
|
while (size) {
|
||||||
int len = sizeof(buffer.out) - buffer.out_bytes;
|
size_t len = sizeof(buffer.out) - buffer.out_bytes;
|
||||||
|
|
||||||
if (len > size)
|
if (len > size)
|
||||||
len = size;
|
len = size;
|
||||||
|
@ -181,18 +183,23 @@ static dc_status_t ble_serial_write(dc_custom_io_t *io, const void* data, size_t
|
||||||
|
|
||||||
static dc_status_t ble_serial_purge(dc_custom_io_t *io, dc_direction_t queue)
|
static dc_status_t ble_serial_purge(dc_custom_io_t *io, dc_direction_t queue)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(io)
|
||||||
|
Q_UNUSED(queue)
|
||||||
/* Do we care? */
|
/* Do we care? */
|
||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dc_status_t ble_serial_get_available(dc_custom_io_t *io, size_t *available)
|
static dc_status_t ble_serial_get_available(dc_custom_io_t *io, size_t *available)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(io)
|
||||||
*available = buffer.in_bytes - buffer.in_pos;
|
*available = buffer.in_bytes - buffer.in_pos;
|
||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dc_status_t ble_serial_set_timeout(dc_custom_io_t *io, long timeout)
|
static dc_status_t ble_serial_set_timeout(dc_custom_io_t *io, long timeout)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(io)
|
||||||
|
Q_UNUSED(timeout)
|
||||||
/* Do we care? */
|
/* Do we care? */
|
||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue