aboutsummaryrefslogtreecommitdiffstats
path: root/core/btdiscovery.h
blob: 796be908a39692f6407f519058174081f525235a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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