summaryrefslogtreecommitdiff
path: root/gatocharacteristic.h
blob: 2b2f4579d4b36ee97c93af506d8e6b775cb2aceb (plain)
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
65
66
67
68
69
#ifndef GATOCHARACTERISTIC_H
#define GATOCHARACTERISTIC_H

#include <QtCore/QObject>
#include <QtCore/QSharedDataPointer>

#include "gatouuid.h"

class GatoCharacteristicPrivate;
class GatoDescriptor;

class LIBGATO_EXPORT GatoCharacteristic
{
	Q_GADGET
	Q_FLAGS(CharacteristicProperties)

public:
	enum Property {
		PropertyBroadcast = 0x1,
		PropertyRead = 0x2,
		PropertyWriteWithoutResponse = 0x4,
		PropertyWrite = 0x5,
		PropertyNotify = 0x10,
		PropertyIndicate = 0x20,
		PropertyAuthenticatedSignedWrites = 0x40,
		PropertyExtendedProperties = 0x80
	};
	Q_DECLARE_FLAGS(Properties, Property)

	GatoCharacteristic();
	GatoCharacteristic(const GatoCharacteristic &o);
	~GatoCharacteristic();

	bool isNull() const;

	GatoUUID uuid() const;
	void setUuid(const GatoUUID &uuid);

	Properties properties() const;
	void setProperties(Properties props);

	GatoHandle startHandle() const;
	void setStartHandle(GatoHandle handle);

	GatoHandle endHandle() const;
	void setEndHandle(GatoHandle handle);

	GatoHandle valueHandle() const;
	void setValueHandle(GatoHandle handle);

	QList<GatoDescriptor> descriptors() const;
	bool containsDescriptor(const GatoDescriptor& descriptor) const;
	bool containsDescriptor(GatoUUID uuid) const;
	bool containsDescriptor(GatoHandle handle) const;
	GatoDescriptor getDescriptor(GatoUUID uuid) const;
	GatoDescriptor getDescriptor(GatoHandle handle) const;
	void addDescriptor(const GatoDescriptor& descriptor);
	void removeDescriptor(const GatoDescriptor& descriptor);
	void clearDescriptors();

	GatoCharacteristic &operator=(const GatoCharacteristic &o);
	
private:
	QSharedDataPointer<GatoCharacteristicPrivate> d;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(GatoCharacteristic::Properties)

#endif // GATOCHARACTERISTIC_H