aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-01-22 11:14:03 +1300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-01-22 11:14:03 +1300
commit01649503fb885a4de46bd2ec34d208ddf28fd1c2 (patch)
treec7423d3a4e6779da02bfb2f12ca99365bb1a68b8
parenta71b7e51d2f95e21759da9191da040972d74c552 (diff)
downloadsubsurface-01649503fb885a4de46bd2ec34d208ddf28fd1c2.tar.gz
BLE debug: make things less verbose
Unless run with '-v -v -v'. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--core/qt-ble.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp
index b2f2edf47..9626042b5 100644
--- a/core/qt-ble.cpp
+++ b/core/qt-ble.cpp
@@ -52,15 +52,18 @@ extern "C" {
void BLEObject::serviceStateChanged(QLowEnergyService::ServiceState newState)
{
- qDebug() << "serviceStateChanged";
+ if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
+ qDebug() << "serviceStateChanged";
auto service = qobject_cast<QLowEnergyService*>(sender());
if (service)
- qDebug() << service->serviceUuid() << newState;
+ if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
+ qDebug() << service->serviceUuid() << newState;
}
void BLEObject::characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value)
{
- qDebug() << QTime::currentTime() << "packet RECV" << value.toHex();
+ if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
+ qDebug() << QTime::currentTime() << "packet RECV" << value.toHex();
if (IS_HW(device)) {
if (c.uuid() == hwAllCharacteristics[HW_OSTC_BLE_DATA_TX]) {
hw_credit--;
@@ -84,14 +87,15 @@ void BLEObject::characteristicWritten(const QLowEnergyCharacteristic &c, const Q
isCharacteristicWritten = true;
}
} else {
- if (debugCounter < DEBUG_THRESHOLD)
+ if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
qDebug() << "BLEObject::characteristicWritten";
}
}
void BLEObject::writeCompleted(const QLowEnergyDescriptor&, const QByteArray&)
{
- qDebug() << "BLE write completed";
+ if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
+ qDebug() << "BLE write completed";
desc_written++;
}
@@ -178,7 +182,8 @@ dc_status_t BLEObject::write(const void *data, size_t size, size_t *actual)
continue;
QByteArray bytes((const char *)data, (int) size);
- qDebug() << QTime::currentTime() << "packet SEND" << bytes.toHex();
+ if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
+ qDebug() << QTime::currentTime() << "packet SEND" << bytes.toHex();
QLowEnergyService::WriteMode mode;
mode = (c.properties() & QLowEnergyCharacteristic::WriteNoResponse) ?
@@ -202,7 +207,8 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)
if (list.isEmpty())
return DC_STATUS_IO;
- qDebug() << QTime::currentTime() << "packet WAIT";
+ if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
+ qDebug() << QTime::currentTime() << "packet WAIT";
WAITFOR(!receivedPackets.isEmpty(), timeout);
if (receivedPackets.isEmpty())
@@ -225,7 +231,8 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)
if (actual)
*actual += packet.size();
- qDebug() << QTime::currentTime() << "packet READ" << packet.toHex();
+ if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
+ qDebug() << QTime::currentTime() << "packet READ" << packet.toHex();
return DC_STATUS_SUCCESS;
}