From 05fe19a23ff4b23fc2d4cbcf84fdc141d4491e4b Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 23 Sep 2018 20:04:08 -0700 Subject: [PATCH] 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 --- core/qt-ble.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp index 4fc2cd5df..8d4003d0f 100644 --- a/core/qt-ble.cpp +++ b/core/qt-ble.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -59,6 +60,7 @@ void BLEObject::serviceStateChanged(QLowEnergyService::ServiceState newState) void BLEObject::characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value) { + qDebug() << QTime::currentTime() << "packet RECV" << value.toHex(); if (IS_HW(device)) { if (c.uuid() == hwAllCharacteristics[HW_OSTC_BLE_DATA_TX]) { hw_credit--; @@ -156,6 +158,7 @@ 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(); QLowEnergyService::WriteMode mode; 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()) return DC_STATUS_IO; + qDebug() << QTime::currentTime() << "packet WAIT"; + WAITFOR(!receivedPackets.isEmpty(), BLE_TIMEOUT); if (receivedPackets.isEmpty()) return DC_STATUS_IO; @@ -193,6 +198,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(); + return DC_STATUS_SUCCESS; }