NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
NimBLEUUID.h
1/*
2 * Copyright 2020-2024 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 "nimconfig.h"
22#if defined(CONFIG_BT_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;
47 NimBLEUUID(const ble_uuid_any_t& uuid);
48 NimBLEUUID(const std::string& uuid);
49 NimBLEUUID(uint16_t uuid);
50 NimBLEUUID(uint32_t uuid);
51 NimBLEUUID(const ble_uuid128_t* uuid);
52 NimBLEUUID(const uint8_t* pData, size_t size);
53 NimBLEUUID(uint32_t first, uint16_t second, uint16_t third, uint64_t fourth);
54
55 uint8_t bitSize() const;
56 const uint8_t* getValue() const;
57 const ble_uuid_t* getBase() const;
58 bool equals(const NimBLEUUID& uuid) const;
59 std::string toString() const;
60 static NimBLEUUID fromString(const std::string& uuid);
61 const NimBLEUUID& to128();
62 const NimBLEUUID& to16();
64
65 bool operator==(const NimBLEUUID& rhs) const;
66 bool operator!=(const NimBLEUUID& rhs) const;
67 operator std::string() const;
68
69 private:
70 ble_uuid_any_t m_uuid{};
71}; // NimBLEUUID
72
73#endif /* CONFIG_BT_ENABLED */
74#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:181
bool operator==(const NimBLEUUID &rhs) const
Convenience operator to check if this UUID is equal to another.
Definition NimBLEUUID.cpp:288
const NimBLEUUID & to16()
Convert 128 bit UUID to its 16 bit representation.
Definition NimBLEUUID.cpp:241
const ble_uuid_t * getBase() const
Get a pointer to the NimBLE UUID base structure.
Definition NimBLEUUID.cpp:171
const NimBLEUUID & to128()
Convert a UUID to its 128 bit representation.
Definition NimBLEUUID.cpp:222
NimBLEUUID()=default
Created a blank UUID.
std::string toString() const
Get a string representation of the UUID.
Definition NimBLEUUID.cpp:264
const NimBLEUUID & reverseByteOrder()
Reverse the byte order of the UUID.
Definition NimBLEUUID.cpp:273
bool operator!=(const NimBLEUUID &rhs) const
Convenience operator to check if this UUID is not equal to another.
Definition NimBLEUUID.cpp:326
const uint8_t * getValue() const
Get the uuid value.
Definition NimBLEUUID.cpp:153
static NimBLEUUID fromString(const std::string &uuid)
Definition NimBLEUUID.cpp:196
uint8_t bitSize() const
Get the bit size of the UUID, 16, 32 or 128.
Definition NimBLEUUID.cpp:144
Definition ble_uuid.h:70
Definition ble_uuid.h:52
Definition ble_uuid.h:76