5#ifndef LIBGULLIBLE_UUID_HPP
6#define LIBGULLIBLE_UUID_HPP
10#include <mlab/any_of.hpp>
15 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
16 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
19 _16 = BLE_UUID_TYPE_16,
20 _32 = BLE_UUID_TYPE_32,
21 _128 = BLE_UUID_TYPE_128
28 template <std::
size_t Size>
30 std::array<std::uint8_t, Size>
d{};
41 inline explicit uuid_data(std::uint16_t d_);
43 [[nodiscard]]
inline std::uint16_t
to_nimble()
const;
45 [[nodiscard]]
inline std::array<std::uint8_t, 16> expand()
const;
52 inline explicit uuid_data(std::uint32_t d_);
54 [[nodiscard]]
inline std::uint32_t
to_nimble()
const;
56 [[nodiscard]]
inline std::array<std::uint8_t, 16> expand()
const;
72 class uuid :
public mlab::any_of<uuid_type, uuid_data> {
80 uuid(std::initializer_list<std::uint8_t>
data);
86 explicit uuid(std::array<std::uint8_t, 2>
data);
88 explicit uuid(std::array<std::uint8_t, 4>
data);
90 explicit uuid(std::array<std::uint8_t, 16>
data);
112 [[nodiscard]] ble_uuid_any_t
to_nimble() const;
114 [[nodiscard]]
bool operator==(
uuid const &other) const;
116 [[nodiscard]]
bool operator!=(
uuid const &other) const;
120 [[nodiscard]] std::
string to_string() const;
127 template <std::
size_t Size>
131 :
uuid_data{{std::uint8_t(d_ & 0xff), std::uint8_t((d_ >> 8) & 0xff)}} {}
134 :
uuid_data{{std::uint8_t(d_ & 0xff), std::uint8_t((d_ >> 8) & 0xff),
135 std::uint8_t((d_ >> 16) & 0xff), std::uint8_t((d_ >> 24) & 0xff)}} {}
138 return std::uint16_t(d[0]) | (std::uint16_t(d[1]) << 8);
142 return std::uint16_t(d[0]) | (std::uint16_t(d[1]) << 8) | (std::uint16_t(d[2]) << 16) |
143 (std::uint16_t(d[3]) << 24);
mlab::bin_data & data
Definition: characteristic.cpp:49
std::string to_string() const
Definition: uuid.cpp:86
uuid & operator=(uuid const &other)
Definition: uuid.cpp:56
uuid as_uuid128() const
Definition: uuid.cpp:73
ble_uuid_any_t to_nimble() const
Definition: uuid.cpp:181
uuid(uuid &&) noexcept=default
uuid()
Definition: uuid.cpp:10
static uuid from_nimble(ble_uuid_t const &ble_uuid)
Definition: uuid.cpp:123
Definition: characteristic.hpp:14
std::uint16_t to_nimble(access_type a)
Definition: characteristic.hpp:212
static constexpr auto cast_uuid16
Definition: uuid.hpp:68
constexpr std::array< uint8_t, 16 > base_uuid
Definition: uuid.hpp:14
static constexpr auto cast_uuid128
Definition: uuid.hpp:70
static constexpr auto cast_uuid32
Definition: uuid.hpp:69
uuid_type
Definition: uuid.hpp:18
std::array< std::uint8_t, Size > d
Definition: uuid.hpp:30
uuid_data_with_length(std::array< std::uint8_t, Size > d_)
Definition: uuid.hpp:128
uuid_data_with_length()=default