NimBLE-Arduino 1.4.2
Loading...
Searching...
No Matches
NimBLEUUID.h
1/*
2 * NimBLEUUID.h
3 *
4 * Created: on Jan 24 2020
5 * Author H2zero
6 *
7 * Originally:
8 *
9 * BLEUUID.h
10 *
11 * Created on: Jun 21, 2017
12 * Author: kolban
13 */
14
15#ifndef COMPONENTS_NIMBLEUUID_H_
16#define COMPONENTS_NIMBLEUUID_H_
17
18#include "nimconfig.h"
19#if defined(CONFIG_BT_ENABLED)
20
21#if defined(CONFIG_NIMBLE_CPP_IDF)
22#include "host/ble_uuid.h"
23#else
24#include "nimble/nimble/host/include/host/ble_uuid.h"
25#endif
26
27/**** FIX COMPILATION ****/
28#undef min
29#undef max
30/**************************/
31
32#include <string>
33
38public:
39 NimBLEUUID(const std::string &uuid);
40 NimBLEUUID(uint16_t uuid);
41 NimBLEUUID(uint32_t uuid);
42 NimBLEUUID(const ble_uuid128_t* uuid);
43 NimBLEUUID(const uint8_t* pData, size_t size, bool msbFirst);
44 NimBLEUUID(uint32_t first, uint16_t second, uint16_t third, uint64_t fourth);
45 NimBLEUUID();
46
47 uint8_t bitSize() const;
48 bool equals(const NimBLEUUID &uuid) const;
49 const ble_uuid_any_t* getNative() const;
50 const NimBLEUUID & to128();
51 const NimBLEUUID& to16();
52 std::string toString() const;
53 static NimBLEUUID fromString(const std::string &uuid);
54
55 bool operator ==(const NimBLEUUID & rhs) const;
56 bool operator !=(const NimBLEUUID & rhs) const;
57 operator std::string() const;
58
59private:
60 ble_uuid_any_t m_uuid;
61 bool m_valueSet = false;
62}; // NimBLEUUID
63#endif /* CONFIG_BT_ENABLED */
64#endif /* COMPONENTS_NIMBLEUUID_H_ */
A model of a BLE UUID.
Definition: NimBLEUUID.h:37
bool equals(const NimBLEUUID &uuid) const
Compare a UUID against this UUID.
Definition: NimBLEUUID.cpp:187
bool operator==(const NimBLEUUID &rhs) const
Convenience operator to check if this UUID is equal to another.
Definition: NimBLEUUID.cpp:302
const NimBLEUUID & to16()
Convert 128 bit UUID to its 16 bit representation.
Definition: NimBLEUUID.cpp:266
const ble_uuid_any_t * getNative() const
Get the native UUID value.
Definition: NimBLEUUID.cpp:227
const NimBLEUUID & to128()
Convert a UUID to its 128 bit representation.
Definition: NimBLEUUID.cpp:242
std::string toString() const
Get a string representation of the UUID.
Definition: NimBLEUUID.cpp:294
NimBLEUUID()
Creates an empty UUID.
Definition: NimBLEUUID.cpp:166
bool operator!=(const NimBLEUUID &rhs) const
Convenience operator to check if this UUID is not equal to another.
Definition: NimBLEUUID.cpp:341
static NimBLEUUID fromString(const std::string &uuid)
Definition: NimBLEUUID.cpp:203
uint8_t bitSize() const
Get the number of bits in this uuid.
Definition: NimBLEUUID.cpp:175