qt-ble: add BLE packet debugging code

This is perhaps overly verbose, but the timing details helped figure out
some EON Core download issues, and it's nice to see when things actually
happen.

It's also good to see when the data actually enters our queues, and when
we read and write the packets.  That might help debug the issues Fabio
is seeing with the Mares Bluelink.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2018-09-23 20:04:08 -07:00 committed by Dirk Hohndel
parent 0ba105d2a7
commit 05fe19a23f

View file

@ -9,6 +9,7 @@
#include <QEventLoop> #include <QEventLoop>
#include <QThread> #include <QThread>
#include <QTimer> #include <QTimer>
#include <QTime>
#include <QDebug> #include <QDebug>
#include <QLoggingCategory> #include <QLoggingCategory>
@ -59,6 +60,7 @@ void BLEObject::serviceStateChanged(QLowEnergyService::ServiceState newState)
void BLEObject::characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value) void BLEObject::characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value)
{ {
qDebug() << QTime::currentTime() << "packet RECV" << value.toHex();
if (IS_HW(device)) { if (IS_HW(device)) {
if (c.uuid() == hwAllCharacteristics[HW_OSTC_BLE_DATA_TX]) { if (c.uuid() == hwAllCharacteristics[HW_OSTC_BLE_DATA_TX]) {
hw_credit--; hw_credit--;
@ -156,6 +158,7 @@ dc_status_t BLEObject::write(const void *data, size_t size, size_t *actual)
continue; continue;
QByteArray bytes((const char *)data, (int) size); QByteArray bytes((const char *)data, (int) size);
qDebug() << QTime::currentTime() << "packet SEND" << bytes.toHex();
QLowEnergyService::WriteMode mode; QLowEnergyService::WriteMode mode;
mode = (c.properties() & QLowEnergyCharacteristic::WriteNoResponse) ? mode = (c.properties() & QLowEnergyCharacteristic::WriteNoResponse) ?
@ -179,6 +182,8 @@ 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;
qDebug() << QTime::currentTime() << "packet WAIT";
WAITFOR(!receivedPackets.isEmpty(), BLE_TIMEOUT); WAITFOR(!receivedPackets.isEmpty(), BLE_TIMEOUT);
if (receivedPackets.isEmpty()) if (receivedPackets.isEmpty())
return DC_STATUS_IO; return DC_STATUS_IO;
@ -193,6 +198,8 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)
if (actual) if (actual)
*actual += packet.size(); *actual += packet.size();
qDebug() << QTime::currentTime() << "packet READ" << packet.toHex();
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
} }