mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
3b993fbaad
commit
b14a522f4f
8 changed files with 305 additions and 199 deletions
64
core/btdiscovery.h
Normal file
64
core/btdiscovery.h
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue