|
ELEC-C7222
Libraries for ELEC C7222 Course Work
|
UUID storage for 16-bit and 128-bit UUIDs. More...
#include <uuid.hpp>

Public Types | |
| enum class | Type : uint8_t { Invalid = 0 , k16Bit = 1 , k128Bit = 2 } |
| UUID representation type. More... | |
| enum class | AttributeType : uint16_t { kPrimaryServiceDeclaration = 0x2800 , kSecondaryServiceDeclaration = 0x2801 , kIncludedServiceDeclaration = 0x2802 , kCharacteristicDeclaration = 0x2803 , kServerCharacteristicConfiguration = 0x2903 , kClientCharacteristicConfiguration = 0x2902 , kCharacteristicUserDescription = 0x2901 , kCharacteristicExtendedProperties = 0x2900 , kCharacteristicPresentationFormat = 0x2904 , kCharacteristicAggregateFormat = 0x2905 } |
| Standard GATT Attribute Type UUIDs (16-bit). More... | |
Public Member Functions | |
| Uuid ()=default | |
| Constructs an invalid/empty UUID. | |
| Uuid (const Uuid &)=default | |
| Copy-constructs a UUID. | |
| Uuid (Uuid &&) noexcept=default | |
| Move-constructs a UUID. | |
| Uuid & | operator= (const Uuid &)=default |
| Copy assignment operator. | |
| Uuid & | operator= (Uuid &&) noexcept=default |
| Move assignment operator. | |
| Uuid (uint16_t uuid16) | |
| Constructs a 16-bit UUID from a numeric value. | |
| Uuid (const uint8_t *uuid, size_t size) | |
| Constructs a UUID from a raw byte buffer. | |
| Uuid (const std::array< uint8_t, 16 > &uuid) | |
| Constructs a 128-bit UUID from an array. | |
| Uuid (const std::array< uint8_t, 2 > &uuid) | |
| Constructs a 16-bit UUID from an array. | |
| Type | type () const |
| Returns the UUID type. | |
| bool | Is16Bit () const |
| Returns true if this UUID is 16-bit. | |
| bool | Is128Bit () const |
| Returns true if this UUID is 128-bit. | |
| bool | IsValid () const |
| Returns true if the UUID has been initialized to 16- or 128-bit. | |
| uint16_t | Get16Bit () const |
| Returns the 16-bit UUID value. | |
| const std::array< uint8_t, 16 > & | Get128Bit () const |
| Returns the 128-bit UUID bytes. | |
| const uint8_t * | data () const |
| Returns the raw UUID storage pointer. | |
| bool | operator== (const Uuid &other) const |
| Equality comparison based on UUID type and value. | |
| bool | operator!= (const Uuid &other) const |
| Inequality comparison based on UUID type and value. | |
Static Public Member Functions | |
| static Uuid | Convert16To128 (const Uuid &uuid16) |
| Converts a 16-bit UUID to a 128-bit Bluetooth base UUID. | |
| static Uuid | PrimaryServiceDeclaration () |
| Create a Primary Service Declaration UUID (0x2800). | |
| static Uuid | SecondaryServiceDeclaration () |
| Create a Secondary Service Declaration UUID (0x2801). | |
| static Uuid | IncludedServiceDeclaration () |
| Create an Included Service Declaration UUID (0x2802). | |
| static Uuid | CharacteristicDeclaration () |
| Create a Characteristic Declaration UUID (0x2803). | |
| static Uuid | ClientCharacteristicConfiguration () |
| Create a Client Characteristic Configuration UUID (0x2902). | |
| static Uuid | ServerCharacteristicConfiguration () |
| Create a Server Characteristic Configuration UUID (0x2903). | |
| static Uuid | CharacteristicUserDescription () |
| Create a Characteristic User Description UUID (0x2901). | |
| static Uuid | CharacteristicExtendedProperties () |
| Create a Characteristic Extended Properties UUID (0x2900). | |
| static Uuid | CharacteristicPresentationFormat () |
| Create a Characteristic Presentation Format UUID (0x2904). | |
| static Uuid | CharacteristicAggregateFormat () |
| Create a Characteristic Aggregate Format UUID (0x2905). | |
| static bool | IsPrimaryServiceDeclaration (const Uuid &uuid) |
| Check if UUID is Primary Service Declaration (0x2800). | |
| static bool | IsSecondaryServiceDeclaration (const Uuid &uuid) |
| Check if UUID is Secondary Service Declaration (0x2801). | |
| static bool | IsIncludedServiceDeclaration (const Uuid &uuid) |
| Check if UUID is Included Service Declaration (0x2802). | |
| static bool | IsCharacteristicDeclaration (const Uuid &uuid) |
| Check if UUID is Characteristic Declaration (0x2803). | |
| static bool | IsServiceDeclaration (const Uuid &uuid) |
| Check if UUID is any Service Declaration (Primary or Secondary). | |
| static bool | IsClientCharacteristicConfiguration (const Uuid &uuid) |
| Check if UUID is Client Characteristic Configuration (0x2902). | |
| static bool | IsServerCharacteristicConfiguration (const Uuid &uuid) |
| Check if UUID is Server Characteristic Configuration (0x2903). | |
| static bool | IsCharacteristicUserDescription (const Uuid &uuid) |
| Check if UUID is Characteristic User Description (0x2901). | |
| static bool | IsCharacteristicExtendedProperties (const Uuid &uuid) |
| Check if UUID is Characteristic Extended Properties (0x2900). | |
| static bool | IsDescriptor (const Uuid &uuid) |
| Check if UUID matches a known descriptor type. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Uuid &uuid) |
| Prints the UUID to a stream. | |
UUID storage for 16-bit and 128-bit UUIDs.
The first two bytes of uuid_ are used for 16-bit UUIDs and the full 16-byte array is used for 128-bit UUIDs. On RP2040, 16-bit UUIDs are stored in little-endian order to match the BTstack ATT DB layout. For 128-bit UUIDs, the byte order matches the standard UUID string format shown by the stream operator.
The class also defines common 16-bit GATT attribute type UUIDs and helper predicates to recognize declaration/descriptor UUIDs.
Example (16-bit construction and access):
Example (128-bit construction and access):
|
strong |
Standard GATT Attribute Type UUIDs (16-bit).
These values identify service/characteristic declarations and common descriptors as defined by Bluetooth Assigned Numbers.
| Enumerator | |
|---|---|
| kPrimaryServiceDeclaration | Primary Service Declaration attribute (0x2800). |
| kSecondaryServiceDeclaration | Secondary Service Declaration attribute (0x2801). |
| kIncludedServiceDeclaration | Included Service Declaration attribute (0x2802). |
| kCharacteristicDeclaration | Characteristic Declaration attribute (0x2803). |
| kServerCharacteristicConfiguration | Server Characteristic Configuration Descriptor (0x2903). |
| kClientCharacteristicConfiguration | Client Characteristic Configuration Descriptor (0x2902). |
| kCharacteristicUserDescription | Characteristic User Description Descriptor (0x2901). |
| kCharacteristicExtendedProperties | Characteristic Extended Properties Descriptor (0x2900). |
| kCharacteristicPresentationFormat | Characteristic Presentation Format Descriptor (0x2904). |
| kCharacteristicAggregateFormat | Characteristic Aggregate Format Descriptor (0x2905). |
|
strong |
|
default |
Constructs an invalid/empty UUID.
|
default |
Copy-constructs a UUID.
|
defaultnoexcept |
Move-constructs a UUID.
|
inlineexplicit |
Constructs a 16-bit UUID from a numeric value.
| uuid16 | 16-bit UUID value (stored in little-endian order). |
| c7222::Uuid::Uuid | ( | const uint8_t * | uuid, |
| size_t | size | ||
| ) |
Constructs a UUID from a raw byte buffer.
| uuid | Pointer to 2 or 16 bytes of UUID data. |
| size | Size of the buffer in bytes (must be 2 or 16). |
For 16-bit UUIDs, the buffer is interpreted as little-endian. For 128-bit UUIDs, the buffer is interpreted in standard byte order.
|
inlineexplicit |
Constructs a 128-bit UUID from an array.
| uuid | 128-bit UUID bytes in standard order. |
|
inlineexplicit |
Constructs a 16-bit UUID from an array.
| uuid | 16-bit UUID bytes in little-endian order. |
|
static |
Create a Characteristic Aggregate Format UUID (0x2905).
|
static |
Create a Characteristic Declaration UUID (0x2803).
|
static |
Create a Characteristic Extended Properties UUID (0x2900).
|
static |
Create a Characteristic Presentation Format UUID (0x2904).
|
static |
Create a Characteristic User Description UUID (0x2901).
|
static |
Create a Client Characteristic Configuration UUID (0x2902).
Converts a 16-bit UUID to a 128-bit Bluetooth base UUID.
| uuid16 | 16-bit UUID to expand. |
|
inline |
Returns the raw UUID storage pointer.
The byte order matches the storage rules documented above.
|
inline |
Returns the 128-bit UUID bytes.
|
inline |
Returns the 16-bit UUID value.
|
static |
Create an Included Service Declaration UUID (0x2802).
| bool c7222::Uuid::Is128Bit | ( | ) | const |
Returns true if this UUID is 128-bit.

|
inline |
Returns true if this UUID is 16-bit.
|
static |
Check if UUID is Characteristic Declaration (0x2803).
|
static |
Check if UUID is Characteristic Extended Properties (0x2900).
|
static |
Check if UUID is Characteristic User Description (0x2901).
|
static |
Check if UUID is Client Characteristic Configuration (0x2902).
|
static |
Check if UUID matches a known descriptor type.
|
static |
Check if UUID is Included Service Declaration (0x2802).
|
static |
Check if UUID is Primary Service Declaration (0x2800).
|
static |
Check if UUID is Secondary Service Declaration (0x2801).
|
static |
Check if UUID is Server Characteristic Configuration (0x2903).
|
static |
Check if UUID is any Service Declaration (Primary or Secondary).
|
inline |
Returns true if the UUID has been initialized to 16- or 128-bit.

|
inline |
Inequality comparison based on UUID type and value.
| other | UUID to compare against. |
| bool c7222::Uuid::operator== | ( | const Uuid & | other | ) | const |
Equality comparison based on UUID type and value.
| other | UUID to compare against. |
|
static |
Create a Primary Service Declaration UUID (0x2800).
|
static |
Create a Secondary Service Declaration UUID (0x2801).
|
static |
Create a Server Characteristic Configuration UUID (0x2903).
|
inline |
Returns the UUID type.
|
friend |
Prints the UUID to a stream.
For 16-bit UUIDs the output is 0xNNNN. For 128-bit UUIDs the output is the standard 8-4-4-4-12 hex format.
This is the definition corresponding to the friend declaration above.