Changeset 18eff8f in subsurface


Ignore:
Timestamp:
May 29, 2017, 3:08:28 PM (4 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
c8c56b3
Parents:
5c4f998
git-author:
Dirk Hohndel <dirk@…> (05/29/17 15:07:57)
git-committer:
Dirk Hohndel <dirk@…> (05/29/17 15:08:28)
Message:

QML UI: detect BT dive computers

If we find something that looks like a known BT dive computer, set
things up so that we can use it later. If multiple dive computers are
found, simply use the first.

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

Location:
mobile-widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mobile-widgets/qmlmanager.cpp

    ra568562 r18eff8f  
    208208{
    209209        QString newDevice = device.name();
     210        QList<QBluetoothUuid> serviceUuids = device.serviceUuids();
     211        foreach (QBluetoothUuid id, serviceUuids) {
     212                qDebug() << id.toByteArray();
     213        }
    210214        appendTextToLog("Found new device " + newDevice + " (" + device.address().toString() + ")");
    211215        QString vendor, product;
     
    213217                if (productList[vendor].contains(newDevice)) {
    214218                        appendTextToLog("this could be a " + vendor + " " + newDevice);
     219                        struct btVendorProduct btVP;
     220                        btVP.btdi = device;
     221                        btVP.vendorIdx = vendorList.indexOf(vendor);
     222                        btVP.productIdx = productList[vendor].indexOf(newDevice);
     223                        qDebug() << "adding new btDCs entry" << newDevice << btVP.vendorIdx << btVP.productIdx;
     224                        btDCs << btVP;
    215225                }
    216226        }
    217227}
    218228#endif
     229
     230int QMLManager::getVendorIndex()
     231{
     232#if BT_SUPPORT
     233        if (!btDCs.isEmpty()) {
     234                qDebug() << "getVendorIdx" << btDCs.first().vendorIdx;
     235                return btDCs.first().vendorIdx;
     236        }
     237#endif
     238        return -1;
     239}
     240
     241int QMLManager::getProductIndex()
     242{
     243#if BT_SUPPORT
     244        if (!btDCs.isEmpty()) {
     245                qDebug() << "getProductIdx" << btDCs.first().productIdx;
     246                return btDCs.first().productIdx;
     247        }
     248#endif
     249        return -1;
     250}
    219251
    220252void QMLManager::finishSetup()
  • mobile-widgets/qmlmanager.h

    r1ab6b50a r18eff8f  
    1111#include <QBluetoothLocalDevice>
    1212#include <QBluetoothDeviceDiscoveryAgent>
     13#include <QBluetoothUuid>
    1314#endif
    1415
     
    119120        void setShowPin(bool enable);
    120121        Q_INVOKABLE QStringList getDCListFromVendor(const QString& vendor);
     122        Q_INVOKABLE int getVendorIndex();
     123        Q_INVOKABLE int getProductIndex();
    121124#if BT_SUPPORT
    122125        void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
     
    207210        QBluetoothLocalDevice localBtDevice;
    208211        QBluetoothDeviceDiscoveryAgent *discoveryAgent;
     212        struct btVendorProduct {
     213                QBluetoothDeviceInfo btdi;
     214                int vendorIdx;
     215                int productIdx;
     216        };
     217        QList<struct btVendorProduct> btDCs;
    209218#endif
    210219
Note: See TracChangeset for help on using the changeset viewer.