mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
BLE: reduce the noise of debug output
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c9c9a8390a
commit
4834f51a73
1 changed files with 18 additions and 1 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
#include <libdivecomputer/version.h>
|
#include <libdivecomputer/version.h>
|
||||||
|
|
||||||
|
@ -21,6 +22,8 @@
|
||||||
#include <libdivecomputer/custom_io.h>
|
#include <libdivecomputer/custom_io.h>
|
||||||
|
|
||||||
#define BLE_TIMEOUT 12000 // 12 seconds seems like a very long time to wait
|
#define BLE_TIMEOUT 12000 // 12 seconds seems like a very long time to wait
|
||||||
|
#define DEBUG_THRESHOLD 20
|
||||||
|
static int debugCounter;
|
||||||
|
|
||||||
#define IS_HW(_d) same_string((_d)->vendor, "Heinrichs Weikamp")
|
#define IS_HW(_d) same_string((_d)->vendor, "Heinrichs Weikamp")
|
||||||
#define IS_SHEARWATER(_d) same_string((_d)->vendor, "Shearwater")
|
#define IS_SHEARWATER(_d) same_string((_d)->vendor, "Shearwater")
|
||||||
|
@ -79,6 +82,7 @@ void BLEObject::characteristicWritten(const QLowEnergyCharacteristic &c, const Q
|
||||||
isCharacteristicWritten = true;
|
isCharacteristicWritten = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (debugCounter < DEBUG_THRESHOLD)
|
||||||
qDebug() << "BLEObject::characteristicWritten";
|
qDebug() << "BLEObject::characteristicWritten";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,6 +128,7 @@ BLEObject::BLEObject(QLowEnergyController *c, dc_user_device_t *d)
|
||||||
{
|
{
|
||||||
controller = c;
|
controller = c;
|
||||||
device = d;
|
device = d;
|
||||||
|
debugCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLEObject::~BLEObject()
|
BLEObject::~BLEObject()
|
||||||
|
@ -271,6 +276,9 @@ dc_status_t BLEObject::setupHwTerminalIo(QList<QLowEnergyCharacteristic> allC)
|
||||||
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)
|
Q_UNUSED(context)
|
||||||
|
debugCounter = 0;
|
||||||
|
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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.
|
||||||
|
@ -398,15 +406,24 @@ dc_status_t qt_ble_close(dc_custom_io_t *io)
|
||||||
|
|
||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
static void checkThreshold()
|
||||||
|
{
|
||||||
|
if (++debugCounter == DEBUG_THRESHOLD) {
|
||||||
|
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = false"));
|
||||||
|
qDebug() << "turning off further BT debug output";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dc_status_t qt_ble_read(dc_custom_io_t *io, void* data, size_t size, size_t *actual)
|
dc_status_t qt_ble_read(dc_custom_io_t *io, void* data, size_t size, size_t *actual)
|
||||||
{
|
{
|
||||||
|
checkThreshold();
|
||||||
BLEObject *ble = (BLEObject *) io->userdata;
|
BLEObject *ble = (BLEObject *) io->userdata;
|
||||||
return ble->read(data, size, actual);
|
return ble->read(data, size, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_status_t qt_ble_write(dc_custom_io_t *io, const void* data, size_t size, size_t *actual)
|
dc_status_t qt_ble_write(dc_custom_io_t *io, const void* data, size_t size, size_t *actual)
|
||||||
{
|
{
|
||||||
|
checkThreshold();
|
||||||
BLEObject *ble = (BLEObject *) io->userdata;
|
BLEObject *ble = (BLEObject *) io->userdata;
|
||||||
return ble->write(data, size, actual);
|
return ble->write(data, size, actual);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue