2017-06-06 02:41:57 +00:00
|
|
|
// 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>
|
2017-06-10 12:22:28 +00:00
|
|
|
#include "core/libdivecomputer.h"
|
2017-06-06 02:41:57 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
#include <QAndroidJniObject>
|
2017-06-11 22:45:46 +00:00
|
|
|
#include <QAndroidJniEnvironment>
|
2017-06-06 02:41:57 +00:00
|
|
|
#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;
|
|
|
|
};
|
Mobile: wrap up fixes for BT download on Android
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>
2017-06-12 08:38:24 +00:00
|
|
|
|
|
|
|
struct btVendorProduct {
|
|
|
|
btPairedDevice btpdi;
|
|
|
|
dc_descriptor_t *dcDescriptor;
|
|
|
|
int vendorIdx;
|
|
|
|
int productIdx;
|
|
|
|
};
|
|
|
|
|
2017-06-06 02:41:57 +00:00
|
|
|
void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
|
Mobile: wrap up fixes for BT download on Android
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>
2017-06-12 08:38:24 +00:00
|
|
|
void btDeviceDiscoveredMain(const btPairedDevice &device);
|
2017-06-06 02:41:57 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
void getBluetoothDevices();
|
|
|
|
#endif
|
Mobile: wrap up fixes for BT download on Android
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>
2017-06-12 08:38:24 +00:00
|
|
|
QList<btVendorProduct> getBtDcs();
|
|
|
|
QList<btVendorProduct> getBtAllDevices();
|
2017-06-06 02:41:57 +00:00
|
|
|
#endif
|
|
|
|
private:
|
|
|
|
static BTDiscovery *m_instance;
|
|
|
|
#if defined(BT_SUPPORT)
|
2017-06-10 08:09:56 +00:00
|
|
|
QList<struct btVendorProduct> btDCs; // recognized DCs
|
|
|
|
QList<struct btVendorProduct> btAllDevices; // all paired BT stuff
|
2017-06-06 02:41:57 +00:00
|
|
|
#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
|