Changeset 6f1590b in subsurface


Ignore:
Timestamp:
Jun 24, 2017, 10:32:47 PM (5 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
d67421c
Parents:
63fc06e
Message:

BLE support: convert fprintf(stderr,...) to qDebug()

This way the output can be seen in the AppLog? on Android.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/qt-ble.cpp

    r63fc06e r6f1590b  
    2626
    2727        Q_FOREACH(QLowEnergyCharacteristic c, list) {
    28                 fprintf(stderr, "   %s\n", c.uuid().toString().toUtf8().data());
     28                qDebug() << "   " << c.uuid().toString();
    2929        }
    3030}
     
    3838void BLEObject::writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &value)
    3939{
    40         fprintf(stderr, "Write completed\n");
     40        qDebug() << "BLE write completed";
    4141}
    4242
     
    4545        const char *uuid = newService.toString().toUtf8().data();
    4646
    47         fprintf(stderr, "Found service %s\n", uuid);
     47        qDebug() << "Found service" << uuid;
    4848        if (uuid[1] == '0') {
    49                 fprintf(stderr, " .. ignoring\n");
     49                qDebug () << " .. ignoring since first digit is '0'";
    5050                return;
    5151        }
    5252        service = controller->createServiceObject(newService, this);
    53         fprintf(stderr, " .. created service object %p\n", service);
     53        qDebug() << " .. created service object" << service;
    5454        if (service) {
    5555                connect(service, &QLowEnergyService::stateChanged, this, &BLEObject::serviceStateChanged);
     
    6767BLEObject::~BLEObject()
    6868{
    69 fprintf(stderr, "Deleting BLE object\n");
     69        qDebug() << "Deleting BLE object";
    7070}
    7171
     
    129129        QLowEnergyController *controller = new QLowEnergyController(remoteDeviceAddress);
    130130
    131 fprintf(stderr, "qt_ble_open(%s)\n", devaddr);
     131        qDebug() << "qt_ble_open(" << devaddr << ")";
    132132
    133133        // Wait until the connection succeeds or until an error occurs
     
    149149        switch (controller->state()) {
    150150        case QLowEnergyController::ConnectedState:
     151                qDebug() << "connected to the controller for device" << devaddr;
    151152                break;
    152153        default:
     154                qDebug() << "failed to connect to the controller " << devaddr << "with error" << controller->errorString();
    153155                report_error("Failed to connect to %s: '%s'", devaddr, controller->errorString().toUtf8().data());
    154156                controller->disconnectFromDevice();
     
    157159        }
    158160
    159 fprintf(stderr, "Connected to device %s\n", devaddr);
    160 
    161161        /* We need to discover services etc here! */
    162162        BLEObject *ble = new BLEObject(controller);
     
    164164        ble->connect(controller, SIGNAL(serviceDiscovered(QBluetoothUuid)), SLOT(addService(QBluetoothUuid)));
    165165
    166 fprintf(stderr, "  .. discovering services\n");
     166        qDebug() << "  .. discovering services";
    167167
    168168        controller->discoverServices();
     
    170170        loop.exec();
    171171
    172 fprintf(stderr, " .. done discovering services\n");
    173 
    174 fprintf(stderr, " .. discovering details\n");
     172        qDebug() << " .. done discovering services";
     173
     174        qDebug() << " .. discovering details";
    175175
    176176        timer.start(msec);
    177177        loop.exec();
    178178
    179 fprintf(stderr, " .. done waiting\n");
    180 
    181 fprintf(stderr, " .. enabling notifications\n");
     179        qDebug() << " .. done waiting";
     180
     181        qDebug() << " .. enabling notifications";
    182182
    183183        /* Enable notifications */
     
    188188                QList<QLowEnergyDescriptor> l = c.descriptors();
    189189
    190 fprintf(stderr, "Descriptor list (%p, %d)\n", l, l.length());
     190                qDebug() << "Descriptor list with" << l.length() << "elements";
     191
     192                QLowEnergyDescriptor d;
     193                foreach(d, l)
     194                        qDebug() << "Descriptor:" << d.name() << "uuid:" << d.uuid().toString();
     195
    191196
    192197                if (!l.isEmpty()) {
    193                         QLowEnergyDescriptor d = l.first();
    194 
    195 fprintf(stderr, "Descriptor: %s uuid: %s\n", d.name().toUtf8().data(), d.uuid().toString().toUtf8().data());
     198                        d = l.first();
     199                        qDebug() << "now writing \"0x0100\" to the first descriptor";
    196200
    197201                        ble->service->writeDescriptor(d, QByteArray::fromHex("0100"));
Note: See TracChangeset for help on using the changeset viewer.