1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QLOWENERGYADVERTISINGPARAMETERS_H
5#define QLOWENERGYADVERTISINGPARAMETERS_H
6
7#include <QtBluetooth/qtbluetoothglobal.h>
8#include <QtBluetooth/qbluetoothaddress.h>
9#include <QtBluetooth/qlowenergycontroller.h>
10#include <QtCore/qlist.h>
11#include <QtCore/qshareddata.h>
12
13QT_BEGIN_NAMESPACE
14
15class QLowEnergyAdvertisingParametersPrivate;
16
17class Q_BLUETOOTH_EXPORT QLowEnergyAdvertisingParameters
18{
19public:
20 QLowEnergyAdvertisingParameters();
21 QLowEnergyAdvertisingParameters(const QLowEnergyAdvertisingParameters &other);
22 ~QLowEnergyAdvertisingParameters();
23
24 QLowEnergyAdvertisingParameters &operator=(const QLowEnergyAdvertisingParameters &other);
25 friend bool operator==(const QLowEnergyAdvertisingParameters &a,
26 const QLowEnergyAdvertisingParameters &b)
27 {
28 return equals(a, b);
29 }
30
31 friend bool operator!=(const QLowEnergyAdvertisingParameters &a,
32 const QLowEnergyAdvertisingParameters &b)
33 {
34 return !equals(a, b);
35 }
36
37 enum Mode { AdvInd = 0x0, AdvScanInd = 0x2, AdvNonConnInd = 0x3 };
38 void setMode(Mode mode);
39 Mode mode() const;
40
41 class Q_BLUETOOTH_EXPORT AddressInfo
42 {
43 public:
44 AddressInfo(const QBluetoothAddress &addr, QLowEnergyController::RemoteAddressType t)
45 : address(addr), type(t) {}
46 AddressInfo() : type(QLowEnergyController::PublicAddress) {}
47
48 QBluetoothAddress address;
49 QLowEnergyController::RemoteAddressType type;
50 friend bool operator==(const AddressInfo &a, const AddressInfo &b) { return equals(a, b); }
51 friend bool operator!=(const AddressInfo &a, const AddressInfo &b) { return !equals(a, b); }
52
53 private:
54 static bool equals(const AddressInfo &a, const AddressInfo &b);
55 };
56
57 enum FilterPolicy {
58 IgnoreWhiteList = 0x00,
59 UseWhiteListForScanning = 0x01,
60 UseWhiteListForConnecting = 0x02,
61 UseWhiteListForScanningAndConnecting = 0x03,
62 };
63 void setWhiteList(const QList<AddressInfo> &whiteList, FilterPolicy policy);
64 QList<AddressInfo> whiteList() const;
65 FilterPolicy filterPolicy() const;
66
67 void setInterval(quint16 minimum, quint16 maximum);
68 int minimumInterval() const;
69 int maximumInterval() const;
70
71 // TODO: own address type
72 // TODO: For ADV_DIRECT_IND: peer address + peer address type
73
74 void swap(QLowEnergyAdvertisingParameters &other) noexcept { d.swap(other&: other.d); }
75
76private:
77 static bool equals(const QLowEnergyAdvertisingParameters &a,
78 const QLowEnergyAdvertisingParameters &b);
79 QSharedDataPointer<QLowEnergyAdvertisingParametersPrivate> d;
80};
81
82Q_DECLARE_SHARED(QLowEnergyAdvertisingParameters)
83
84QT_END_NAMESPACE
85
86#endif // Include guard
87

source code of qtconnectivity/src/bluetooth/qlowenergyadvertisingparameters.h