mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
23df593817
Major functional change in this commit is the addition of found static BT devices to the internal administration (on Android), in a way that is equivalent to mobile-on-desktop. So, in both cases, the list of devices in the app are as in the list of devices on the host OS (Linux or Android). To minimize code duplication, the btDeviceDiscovered slot is split in two parts, the part to act as slot for the Qt BT discovery agent (Linux, so mobile-on-desktop), and the part only needed for Android. Remaining to be fixed: the correct handling of the QML UI selection of vendor/product. The first default dive computer is correctly detected, all paired devices from the virtual vendow can be selected, but clicking through vendors results in non logical selections. It is obvious why this is, but a fix is not straigforward at this point. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
75 lines
1.6 KiB
C++
75 lines
1.6 KiB
C++
// 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>
|
|
#include "core/libdivecomputer.h"
|
|
|
|
|
|
|
|
static dc_descriptor_t *getDeviceType(QString btName);
|
|
|
|
#endif
|
|
#if defined(Q_OS_ANDROID)
|
|
#include <QAndroidJniObject>
|
|
#include <QAndroidJniEnvironment>
|
|
#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;
|
|
};
|
|
|
|
struct btVendorProduct {
|
|
btPairedDevice btpdi;
|
|
dc_descriptor_t *dcDescriptor;
|
|
int vendorIdx;
|
|
int productIdx;
|
|
};
|
|
|
|
void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
|
|
void btDeviceDiscoveredMain(const btPairedDevice &device);
|
|
#if defined(Q_OS_ANDROID)
|
|
void getBluetoothDevices();
|
|
#endif
|
|
QList<btVendorProduct> getBtDcs();
|
|
QList<btVendorProduct> getBtAllDevices();
|
|
#endif
|
|
private:
|
|
static BTDiscovery *m_instance;
|
|
#if defined(BT_SUPPORT)
|
|
QList<struct btVendorProduct> btDCs; // recognized DCs
|
|
QList<struct btVendorProduct> btAllDevices; // all paired BT stuff
|
|
#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
|