DtkBluetooth
BlueZ DBus interface binding for Qt
dbluetoothadapter.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DBLUETOOTHADAPTER_H
6#define DBLUETOOTHADAPTER_H
7
8#include "dbluetoothdevice.h"
9#include "dbluetoothtypes.h"
10#include <QScopedPointer>
11#include <DExpected>
12#include <DObject>
13
14DBLUETOOTH_BEGIN_NAMESPACE
15
16using DTK_CORE_NAMESPACE::DExpected;
17using DTK_CORE_NAMESPACE::DObject;
18
19class DManager;
20
21class DAdapterPrivate;
22
23class DAdapter : public QObject, public DObject
24{
25 Q_OBJECT
26 explicit DAdapter(quint64 adapter, QObject *parent = nullptr);
27 friend class DManager;
28
29public:
30 ~DAdapter() override;
31
32 Q_PROPERTY(QString address READ address CONSTANT)
33 Q_PROPERTY(DDevice::AddressType addressType READ addressType NOTIFY addressTypeChanged)
34 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
35 Q_PROPERTY(QString alias READ alias WRITE setAlias NOTIFY aliasChanged)
36 Q_PROPERTY(bool powered READ powered WRITE setPowered NOTIFY poweredChanged)
37 Q_PROPERTY(bool discoverable READ discoverable WRITE setDiscoverable NOTIFY discoverableChanged)
38 Q_PROPERTY(
39 quint32 discoverableTimeout READ discoverableTimeout WRITE setDiscoverableTimeout NOTIFY discoverableTimeoutChanged)
40 Q_PROPERTY(bool discovering READ discovering NOTIFY discoveringChanged)
41
42 QString address() const;
43 DDevice::AddressType addressType() const;
44 QString name() const;
45 QString alias() const;
46 void setAlias(const QString &alias);
47 bool powered() const;
48 void setPowered(bool powered);
49 bool discoverable() const;
50 void setDiscoverable(bool discoverable);
51 quint32 discoverableTimeout() const;
52 void setDiscoverableTimeout(quint32 discoverableTimeout);
53 bool discovering() const;
54
55 DExpected<QSharedPointer<DDevice>> deviceFromAddress(const QString &deviceAddress) const;
56 DExpected<QStringList> devices() const;
57public Q_SLOTS:
58 DExpected<void> removeDevice(const QString &device) const;
59 DExpected<void> startDiscovery() const;
60 DExpected<void> stopDiscovery() const;
61
62Q_SIGNALS:
63 void addressTypeChanged(DDevice::AddressType type);
64 void nameChanged(const QString &name);
65 void aliasChanged(const QString &alias);
66 void poweredChanged(bool powered);
67 void discoverableChanged(bool discoverable);
68 void discoverableTimeoutChanged(quint32 discoverableTimeout);
69 void discoveringChanged(bool discovering);
70
71 void removed();
72 void deviceAdded(const QString &deviceAddress);
73 void deviceRemoved(const QString &deviceAddress);
74
75private:
76 D_DECLARE_PRIVATE(DAdapter);
77};
78
79DBLUETOOTH_END_NAMESPACE
80#endif
对于蓝牙适配器的封装
Definition: dbluetoothadapter.h:24
对于蓝牙设备的封装
Definition: dbluetoothdevice.h:22
AddressType
Definition: dbluetoothdevice.h:31
蓝牙管理类, DAdapter对象由此创建
Definition: dbluetoothmanager.h:22
一些自定义类型和枚举