pabigot  0.1.1
C++ support classes
Public Member Functions | Static Public Attributes
pabigot::ble::uuid128_type Class Reference

Basic holder for 128-bit UUIDs stored as a little-endian byte sequence. More...

#include </mnt/devel/pabigot-cxx/include/pabigot/ble.hpp>

Inheritance diagram for pabigot::ble::uuid128_type:
pabigot::ble::details::uuid_type< 16 >

Public Member Functions

std::string as_string () const noexcept
 Convert the UUID to its standard text representation. More...
 
bool base_match (const uuid128_type &other) const noexcept
 Indicate whether the two UUIDs have the same base UUID. More...
 
uuid128_type from_uuid16 (const uuid16_type &uuid16) const noexcept
 Construct a derived 128-bit UUID from a 16-bit UUID. More...
 
uuid128_type from_uuid16 (uint16_t uuid16) const noexcept
 Construct a derived 128-bit UUID from a 16-bit UUID integral value. More...
 
uuid16_type::integer_type uuid16 () const noexcept
 Extract the 16-bit UUID as a host byte order integer.
 
uuid128_type swap_endian () const noexcept
 Byte-reverse the UUID, converting between big- and little-endian representations. More...
 
- Public Member Functions inherited from pabigot::ble::details::uuid_type< 16 >
constexpr uuid_type (const super_type &arr)
 
constexpr uuid_type (super_type &arr)
 
constexpr uuid_type (const uint8_t(&arr)[byte_length])
 
constexpr uuid_type (uint8_t(&arr)[byte_length])
 

Static Public Attributes

static const uuid128_type BLUETOOTH_BASE
 The Bluetooth Base UUID. More...
 
- Static Public Attributes inherited from pabigot::ble::details::uuid_type< 16 >
static constexpr std::size_t byte_length
 The length of the UUID in bytes.
 
static constexpr std::size_t bit_length
 The length of the UUID in bits.
 

Additional Inherited Members

- Public Types inherited from pabigot::ble::details::uuid_type< 16 >
using super_type = std::array< uint8_t, nb >
 

Detailed Description

Basic holder for 128-bit UUIDs stored as a little-endian byte sequence.

To generate an initializer for a 128-bit UUID use:

UUID=${UUID:-$(uuidgen)}
# Optionally clear bits [96, 112) to set as base for 16-bit UUIDs
# UUID=$(echo ${UUID} | sed -r -e 's@^(....)....@\10000@')
echo "// UUID: ${UUID}"
echo ${UUID} \
  | sed -r \
      -e 's@-@@g' \
      -e 's@(..)@0x&,\n@g' \
  | sed -e '/^$/d' \
  | tac \
  | paste -d' ' - - - -
unset UUID

Member Function Documentation

◆ as_string()

std::string pabigot::ble::uuid128_type::as_string ( ) const
noexcept

Convert the UUID to its standard text representation.

Note
Standard text representation is the canonical 8-4-4-4-12 lower-case text of the big-endian byte order as in RFC 4122.

◆ base_match()

bool pabigot::ble::uuid128_type::base_match ( const uuid128_type other) const
noexcept

Indicate whether the two UUIDs have the same base UUID.

Base UUIDs are assumed to be for 16-bit UUIDs, meaning this succeeds if the UUIDs are equal in all but bits [96, 112).

◆ from_uuid16() [1/2]

uuid128_type pabigot::ble::uuid128_type::from_uuid16 ( const uuid16_type uuid16) const
noexcept

Construct a derived 128-bit UUID from a 16-bit UUID.

This returns a new 128-bit UUID equal to this UUID but with bits [96, 112) replaced by the contents of uuid16.

◆ from_uuid16() [2/2]

uuid128_type pabigot::ble::uuid128_type::from_uuid16 ( uint16_t  uuid16) const
inlinenoexcept

Construct a derived 128-bit UUID from a 16-bit UUID integral value.

This returns a new 128-bit UUID equal to this UUID but with bits [96, 112) replaced by the contents of uuid16 in little-endian byte order.

◆ swap_endian()

uuid128_type pabigot::ble::uuid128_type::swap_endian ( ) const
noexcept

Byte-reverse the UUID, converting between big- and little-endian representations.

Note
This operation reverses the entire 16-byte sequence, to meet the expectations of the Nordic Soft Device API. Unlike Microsoft the endianness is not isolated within UUID data elements.

Field Documentation

◆ BLUETOOTH_BASE

const uuid128_type pabigot::ble::uuid128_type::BLUETOOTH_BASE
static

The Bluetooth Base UUID.

I.e.: 00000000-0000-1000-8000-00805F9B34FB


The documentation for this class was generated from the following file: