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>
|
2017-07-17 04:45:21 +00:00
|
|
|
#include <QAbstractListModel>
|
2017-06-06 02:41:57 +00:00
|
|
|
#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
|
|
|
|
|
|
|
#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
|
|
|
|
|
2017-09-17 03:19:41 +00:00
|
|
|
void saveBtDeviceInfo(const char* devaddr, QBluetoothDeviceInfo deviceInfo);
|
|
|
|
QBluetoothDeviceInfo getBtDeviceInfo(const char* devaddr);
|
|
|
|
|
2017-06-06 02:41:57 +00:00
|
|
|
class BTDiscovery : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
BTDiscovery(QObject *parent = NULL);
|
|
|
|
~BTDiscovery();
|
|
|
|
static BTDiscovery *instance();
|
|
|
|
|
|
|
|
struct btPairedDevice {
|
2017-06-30 02:47:51 +00:00
|
|
|
QString address;
|
2017-06-06 02:41:57 +00:00
|
|
|
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-07-12 11:13:25 +00:00
|
|
|
bool btAvailable() const;
|
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();
|
2017-10-06 14:52:17 +00:00
|
|
|
|
2017-06-06 02:41:57 +00:00
|
|
|
private:
|
|
|
|
static BTDiscovery *m_instance;
|
2017-07-12 11:13:25 +00:00
|
|
|
bool m_btValid;
|
2017-10-06 14:52:17 +00:00
|
|
|
|
2017-06-10 08:09:56 +00:00
|
|
|
QList<struct btVendorProduct> btDCs; // recognized DCs
|
|
|
|
QList<struct btVendorProduct> btAllDevices; // all paired BT stuff
|
2017-10-06 14:52:17 +00:00
|
|
|
|
2017-06-06 02:41:57 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
bool checkException(const char* method, const QAndroidJniObject* obj);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QList<struct btPairedDevice> btPairedDevices;
|
|
|
|
QBluetoothLocalDevice localBtDevice;
|
|
|
|
QBluetoothDeviceDiscoveryAgent *discoveryAgent;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void dcVendorChanged();
|
|
|
|
void dcProductChanged();
|
|
|
|
void dcBtChanged();
|
|
|
|
};
|
|
|
|
#endif // BTDISCOVERY_H
|