mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
5142d7409f
This adds a central function to convert a BT name to a vendor/product pair known to Subsurface. This allows interfacing from a paired BT dive computer, without actively selecting its type, but by selecting it from the list of paired BT devices. So, after this, downloading from multiple (paired) DCs is also possible. And not the niced piece of code ... Signed-off-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
71 lines
1.6 KiB
C++
71 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"
|
|
|
|
struct btVendorProduct {
|
|
QBluetoothDeviceInfo btdi;
|
|
dc_descriptor_t *dcDescriptor;
|
|
int vendorIdx;
|
|
int productIdx;
|
|
};
|
|
|
|
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;
|
|
};
|
|
void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
|
|
#if defined(Q_OS_ANDROID)
|
|
void getBluetoothDevices();
|
|
#endif
|
|
QList<struct btVendorProduct> getBtDcs();
|
|
QList<struct 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
|