Changeset 4834f51 in subsurface


Ignore:
Timestamp:
Jul 6, 2017, 9:35:04 AM (2 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
ed43b5d
Parents:
c9c9a839
git-author:
Dirk Hohndel <dirk@…> (07/06/17 07:21:04)
git-committer:
Dirk Hohndel <dirk@…> (07/06/17 09:35:04)
Message:

BLE: reduce the noise of debug output

Signed-off-by: Dirk Hohndel <dirk@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/qt-ble.cpp

    ra8468ca r4834f51  
    1111#include <QTimer>
    1212#include <QDebug>
     13#include <QLoggingCategory>
    1314
    1415#include <libdivecomputer/version.h>
     
    2223
    2324#define BLE_TIMEOUT 12000 // 12 seconds seems like a very long time to wait
     25#define DEBUG_THRESHOLD 20
     26static int debugCounter;
    2427
    2528#define IS_HW(_d) same_string((_d)->vendor, "Heinrichs Weikamp")
     
    8083                }
    8184        } else {
    82                 qDebug() << "BLEObject::characteristicWritten";
     85                if (debugCounter < DEBUG_THRESHOLD)
     86                        qDebug() << "BLEObject::characteristicWritten";
    8387        }
    8488}
     
    125129        controller = c;
    126130        device = d;
     131        debugCounter = 0;
    127132}
    128133
     
    272277{
    273278        Q_UNUSED(context)
     279        debugCounter = 0;
     280        QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
     281
    274282        /*
    275283         * LE-only devices get the "LE:" prepended by the scanning
     
    399407        return DC_STATUS_SUCCESS;
    400408}
     409static void checkThreshold()
     410{
     411        if (++debugCounter == DEBUG_THRESHOLD) {
     412                QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = false"));
     413                qDebug() << "turning off further BT debug output";
     414        }
     415}
    401416
    402417dc_status_t qt_ble_read(dc_custom_io_t *io, void* data, size_t size, size_t *actual)
    403418{
     419        checkThreshold();
    404420        BLEObject *ble = (BLEObject *) io->userdata;
    405421        return ble->read(data, size, actual);
     
    408424dc_status_t qt_ble_write(dc_custom_io_t *io, const void* data, size_t size, size_t *actual)
    409425{
     426        checkThreshold();
    410427        BLEObject *ble = (BLEObject *) io->userdata;
    411428        return ble->write(data, size, actual);
Note: See TracChangeset for help on using the changeset viewer.