esp-nimble-cpp 2.4.0
Loading...
Searching...
No Matches
NimBLEUUID.h
1/*
2 * Copyright 2020-2025 Ryan Powell <ryan@nable-embedded.io> and
3 * esp-nimble-cpp, NimBLE-Arduino contributors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef NIMBLE_CPP_UUID_H_
19#define NIMBLE_CPP_UUID_H_
20
21#include "syscfg/syscfg.h"
22#if CONFIG_BT_NIMBLE_ENABLED
23
24# if defined(CONFIG_NIMBLE_CPP_IDF)
25# include "host/ble_uuid.h"
26# else
27# include "nimble/nimble/host/include/host/ble_uuid.h"
28# endif
29
30/**** FIX COMPILATION ****/
31# undef min
32# undef max
33/**************************/
34
35# include <string>
36# include <cstring>
37
42 public:
46 NimBLEUUID() = default;
49 NimBLEUUID(const std::string& uuid);
53 NimBLEUUID(const uint8_t* pData, size_t size);
55
56 uint8_t bitSize() const;
57 const uint8_t* getValue() const;
58 const ble_uuid_t* getBase() const;
59 bool equals(const NimBLEUUID& uuid) const;
60 std::string toString() const;
61 static NimBLEUUID fromString(const std::string& uuid);
62 const NimBLEUUID& to128();
63 const NimBLEUUID& to16();
65
66 bool operator==(const NimBLEUUID& rhs) const;
67 bool operator!=(const NimBLEUUID& rhs) const;
68 operator std::string() const;
69
70 private:
71 ble_uuid_any_t m_uuid{};
72}; // NimBLEUUID
73
74#endif // CONFIG_BT_NIMBLE_ENABLED
75#endif // NIMBLE_CPP_UUID_H_
A model of a BLE UUID.
Definition NimBLEUUID.h:41
bool equals(const NimBLEUUID &uuid) const
Compare a UUID against this UUID.
Definition NimBLEUUID.cpp:194
bool operator==(const NimBLEUUID &rhs) const
Convenience operator to check if this UUID is equal to another.
Definition NimBLEUUID.cpp:301
const NimBLEUUID & to16()
Convert 128 bit UUID to its 16 bit representation.
Definition NimBLEUUID.cpp:254
const ble_uuid_t * getBase() const
Get a pointer to the NimBLE UUID base structure.
Definition NimBLEUUID.cpp:184
const NimBLEUUID & to128()
Convert a UUID to its 128 bit representation.
Definition NimBLEUUID.cpp:235
NimBLEUUID()=default
Created a blank UUID.
std::string toString() const
Get a string representation of the UUID.
Definition NimBLEUUID.cpp:277
const NimBLEUUID & reverseByteOrder()
Reverse the byte order of the UUID.
Definition NimBLEUUID.cpp:286
bool operator!=(const NimBLEUUID &rhs) const
Convenience operator to check if this UUID is not equal to another.
Definition NimBLEUUID.cpp:339
const uint8_t * getValue() const
Get the uuid value.
Definition NimBLEUUID.cpp:166
static NimBLEUUID fromString(const std::string &uuid)
Definition NimBLEUUID.cpp:209
uint8_t bitSize() const
Get the bit size of the UUID, 16, 32 or 128.
Definition NimBLEUUID.cpp:157