Changeset 286bac6 in subsurface


Ignore:
Timestamp:
May 31, 2017, 10:15:40 AM (6 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
4e16bd7
Parents:
782caf5
git-author:
Dirk Hohndel <dirk@…> (05/30/17 17:50:31)
git-committer:
Dirk Hohndel <dirk@…> (05/31/17 10:15:40)
Message:

Android: connect to BT via uuid instead of port

We remember the offered service uuids as we detect the device and then
try the first one - likely this needs to be fixed / tuned to pick the
right one if multiple uuids are offered.

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

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • core/qtserialbluetooth.cpp

    rb368ecd r286bac6  
    2020#include <libdivecomputer/custom_serial.h>
    2121
     22QList<QBluetoothUuid> registeredUuids;
     23
     24static QBluetoothUuid getBtUuid()
     25{
     26        return registeredUuids.first();
     27}
     28
     29void addBtUuid(QBluetoothUuid uuid)
     30{
     31        registeredUuids << uuid;
     32}
     33
    2234extern "C" {
    2335typedef struct qt_serial_t {
     
    3244        long timeout;
    3345} qt_serial_t;
     46
    3447
    3548static dc_status_t qt_serial_open(void **userdata, const char* devaddr)
     
    134147        // Try to connect to the device using the uuid of the Serial Port Profile service
    135148        QBluetoothAddress remoteDeviceAddress(devaddr);
     149#if defined(Q_OS_ANDROID)
     150        QBluetoothUuid uuid = getBtUuid();
     151        qDebug() << "connecting to Uuid" << uuid;
     152        serial_port->socket->connectToService(remoteDeviceAddress, uuid, QIODevice::ReadWrite | QIODevice::Unbuffered);
     153#else
    136154        serial_port->socket->connectToService(remoteDeviceAddress, 1, QIODevice::ReadWrite | QIODevice::Unbuffered);
     155#endif
    137156        timer.start(msec);
    138157        loop.exec();
  • mobile-widgets/qmlmanager.cpp

    rbe271e7 r286bac6  
    205205
    206206#if BT_SUPPORT
     207
     208extern void addBtUuid(QBluetoothUuid uuid);
     209
    207210void QMLManager::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
    208211{
     
    210213        QList<QBluetoothUuid> serviceUuids = device.serviceUuids();
    211214        foreach (QBluetoothUuid id, serviceUuids) {
     215                addBtUuid(id);
    212216                qDebug() << id.toByteArray();
    213217        }
Note: See TracChangeset for help on using the changeset viewer.