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 QLOWENERGYADVERTISINGDATA_H
5#define QLOWENERGYADVERTISINGDATA_H
6
7#include <QtBluetooth/qtbluetoothglobal.h>
8#include <QtBluetooth/qbluetoothuuid.h>
9#include <QtCore/qshareddata.h>
10
11QT_BEGIN_NAMESPACE
12
13class QLowEnergyAdvertisingDataPrivate;
14
15class Q_BLUETOOTH_EXPORT QLowEnergyAdvertisingData
16{
17public:
18 QLowEnergyAdvertisingData();
19 QLowEnergyAdvertisingData(const QLowEnergyAdvertisingData &other);
20 ~QLowEnergyAdvertisingData();
21
22 QLowEnergyAdvertisingData &operator=(const QLowEnergyAdvertisingData &other);
23 friend bool operator==(const QLowEnergyAdvertisingData &a, const QLowEnergyAdvertisingData &b)
24 {
25 return equals(a, b);
26 }
27 friend bool operator!=(const QLowEnergyAdvertisingData &a, const QLowEnergyAdvertisingData &b)
28 {
29 return !equals(a, b);
30 }
31
32 void setLocalName(const QString &name);
33 QString localName() const;
34
35 static quint16 invalidManufacturerId() { return 0xffff; }
36 void setManufacturerData(quint16 id, const QByteArray &data);
37 quint16 manufacturerId() const;
38 QByteArray manufacturerData() const;
39
40 void setIncludePowerLevel(bool doInclude);
41 bool includePowerLevel() const;
42
43 enum Discoverability {
44 DiscoverabilityNone, DiscoverabilityLimited, DiscoverabilityGeneral
45 };
46 void setDiscoverability(Discoverability mode);
47 Discoverability discoverability() const;
48
49 void setServices(const QList<QBluetoothUuid> &services);
50 QList<QBluetoothUuid> services() const;
51
52 // TODO: BR/EDR capability flag?
53
54 void setRawData(const QByteArray &data);
55 QByteArray rawData() const;
56
57 void swap(QLowEnergyAdvertisingData &other) noexcept { d.swap(other&: other.d); }
58
59private:
60 static bool equals(const QLowEnergyAdvertisingData &a, const QLowEnergyAdvertisingData &b);
61 QSharedDataPointer<QLowEnergyAdvertisingDataPrivate> d;
62};
63
64Q_DECLARE_SHARED(QLowEnergyAdvertisingData)
65
66QT_END_NAMESPACE
67
68#endif // Include guard
69

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