summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-29 11:56:13 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-29 12:00:27 -0700
commit1ab6b50a34a0127b1802b0439b9317d0245b6769 (patch)
tree292f9f2ce232048ba0d346db069f958f9e6a15ae /mobile-widgets/qmlmanager.cpp
parent9bea9fcdb701bfd3bb21ed850248e09bb9127b68 (diff)
downloadsubsurface-1ab6b50a34a0127b1802b0439b9317d0245b6769.tar.gz
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@hohndel.org>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r--mobile-widgets/qmlmanager.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 4d2999049..f10564a94 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -89,6 +89,18 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
m_credentialStatus(UNKNOWN),
alreadySaving(false)
{
+#if BT_SUPPORT
+ if (localBtDevice.isValid()) {
+ localBtDevice.powerOn();
+ QString localDeviceName = "localDevice " + localBtDevice.name() + " is valid, starting discovery";
+ appendTextToLog(localDeviceName.toUtf8().data());
+ discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
+ connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &QMLManager::btDeviceDiscovered);
+ discoveryAgent->start();
+ } else {
+ appendTextToLog("localBtDevice isn't valid");
+ }
+#endif
m_instance = this;
m_lastDevicePixelRatio = qApp->devicePixelRatio();
connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged);
@@ -191,6 +203,14 @@ void QMLManager::mergeLocalRepo()
process_dives(true, false);
}
+#if BT_SUPPORT
+void QMLManager::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
+{
+ QString newDevice = "Found new device " + device.name() + " (" + device.address().toString() + ")";
+ appendTextToLog(newDevice);
+}
+#endif
+
void QMLManager::finishSetup()
{
// Initialize cloud credentials.