summaryrefslogtreecommitdiffstats
path: root/core/btdiscovery.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-06-05 19:41:57 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-06-11 13:55:41 -0700
commitb14a522f4f308aed41ab49b5529cc10c05168716 (patch)
tree2b3540e4aeefbe9c21ab9d3af1af2b07a4f503e0 /core/btdiscovery.h
parent3b993fbaad0738efe54e797b60e4f49270951323 (diff)
downloadsubsurface-b14a522f4f308aed41ab49b5529cc10c05168716.tar.gz
QML UI: move BT handling into core code
This shouldn't be part of the UI (qmlmanager), but part of our overall handling of dive computers and BT devices. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/btdiscovery.h')
-rw-r--r--core/btdiscovery.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/core/btdiscovery.h b/core/btdiscovery.h
new file mode 100644
index 000000000..796be908a
--- /dev/null
+++ b/core/btdiscovery.h
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef BTDISCOVERY_H
+#define BTDISCOVERY_H
+
+#include <QObject>
+#include <QString>
+#include <QLoggingCategory>
+#if defined(BT_SUPPORT)
+#include <QBluetoothLocalDevice>
+#include <QBluetoothDeviceDiscoveryAgent>
+#include <QBluetoothUuid>
+
+struct btVendorProduct {
+ QBluetoothDeviceInfo btdi;
+ int vendorIdx;
+ int productIdx;
+};
+
+#endif
+#if defined(Q_OS_ANDROID)
+#include <QAndroidJniObject>
+#endif
+
+class BTDiscovery : public QObject {
+ Q_OBJECT
+
+public:
+ BTDiscovery(QObject *parent = NULL);
+ ~BTDiscovery();
+ static BTDiscovery *instance();
+
+#if defined(BT_SUPPORT)
+ struct btPairedDevice {
+ QBluetoothAddress address;
+ QString name;
+ };
+ void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
+#if defined(Q_OS_ANDROID)
+ void getBluetoothDevices();
+#endif
+ QList<struct btVendorProduct> getBtDcs();
+#endif
+private:
+ static BTDiscovery *m_instance;
+#if defined(BT_SUPPORT)
+ QList<struct btVendorProduct> btDCs;
+#endif
+#if defined(Q_OS_ANDROID)
+ bool checkException(const char* method, const QAndroidJniObject* obj);
+#endif
+
+#if defined(BT_SUPPORT)
+ QList<struct btPairedDevice> btPairedDevices;
+ QBluetoothLocalDevice localBtDevice;
+ QBluetoothDeviceDiscoveryAgent *discoveryAgent;
+#endif
+
+signals:
+ void dcVendorChanged();
+ void dcProductChanged();
+ void dcBtChanged();
+};
+
+#endif // BTDISCOVERY_H