Changeset 1ab6b50a in subsurface


Ignore:
Timestamp:
May 29, 2017, 12:00:27 PM (7 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
81277c2
Parents:
9bea9fc
git-author:
Dirk Hohndel <dirk@…> (05/29/17 11:56:13)
git-committer:
Dirk Hohndel <dirk@…> (05/29/17 12:00:27)
Message:

QML UI: start BT discovery

So far all this does is list all the BT devices that it finds
(and I worry if this will have negative battery implications
on a mobile device), but this should allow us to connect to
a standard BT dive computer (but that will of course require
more code to pick the right device).

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

Location:
mobile-widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mobile-widgets/qmlmanager.cpp

    r0e4c996 r1ab6b50a  
    9090        alreadySaving(false)
    9191{
     92#if BT_SUPPORT
     93        if (localBtDevice.isValid()) {
     94                localBtDevice.powerOn();
     95                QString localDeviceName = "localDevice " + localBtDevice.name() + " is valid, starting discovery";
     96                appendTextToLog(localDeviceName.toUtf8().data());
     97                discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
     98                connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &QMLManager::btDeviceDiscovered);
     99                discoveryAgent->start();
     100        } else {
     101                appendTextToLog("localBtDevice isn't valid");
     102        }
     103#endif
    92104        m_instance = this;
    93105        m_lastDevicePixelRatio = qApp->devicePixelRatio();
     
    191203        process_dives(true, false);
    192204}
     205
     206#if BT_SUPPORT
     207void QMLManager::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
     208{
     209        QString newDevice = "Found new device " + device.name() + " (" + device.address().toString() + ")";
     210        appendTextToLog(newDevice);
     211}
     212#endif
    193213
    194214void QMLManager::finishSetup()
  • mobile-widgets/qmlmanager.h

    r0e4c996 r1ab6b50a  
    88#include <QScreen>
    99#include <QElapsedTimer>
     10#if BT_SUPPORT
     11#include <QBluetoothLocalDevice>
     12#include <QBluetoothDeviceDiscoveryAgent>
     13#endif
    1014
    1115#include "core/gpslocation.h"
     
    115119        void setShowPin(bool enable);
    116120        Q_INVOKABLE QStringList getDCListFromVendor(const QString& vendor);
     121#if BT_SUPPORT
     122        void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
     123#endif
    117124
    118125public slots:
     
    197204        bool currentGitLocalOnly;
    198205        bool m_showPin;
     206#if BT_SUPPORT
     207        QBluetoothLocalDevice localBtDevice;
     208        QBluetoothDeviceDiscoveryAgent *discoveryAgent;
     209#endif
    199210
    200211signals:
Note: See TracChangeset for help on using the changeset viewer.