BLE debug: make things less verbose

Unless run with '-v -v -v'.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2019-01-22 11:14:03 +13:00
parent a71b7e51d2
commit 01649503fb

View file

@ -52,14 +52,17 @@ extern "C" {
void BLEObject::serviceStateChanged(QLowEnergyService::ServiceState newState)
{
if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
qDebug() << "serviceStateChanged";
auto service = qobject_cast<QLowEnergyService*>(sender());
if (service)
if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
qDebug() << service->serviceUuid() << newState;
}
void BLEObject::characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value)
{
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]) {
@ -84,13 +87,14 @@ 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&)
{
if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
qDebug() << "BLE write completed";
desc_written++;
}
@ -178,6 +182,7 @@ dc_status_t BLEObject::write(const void *data, size_t size, size_t *actual)
continue;
QByteArray bytes((const char *)data, (int) size);
if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
qDebug() << QTime::currentTime() << "packet SEND" << bytes.toHex();
QLowEnergyService::WriteMode mode;
@ -202,6 +207,7 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)
if (list.isEmpty())
return DC_STATUS_IO;
if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
qDebug() << QTime::currentTime() << "packet WAIT";
WAITFOR(!receivedPackets.isEmpty(), timeout);
@ -225,6 +231,7 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)
if (actual)
*actual += packet.size();
if (verbose > 2 || debugCounter < DEBUG_THRESHOLD)
qDebug() << QTime::currentTime() << "packet READ" << packet.toHex();
return DC_STATUS_SUCCESS;