esp-nimble-cpp 2.0.1
|
A model of a BLE UUID. More...
#include <NimBLEUUID.h>
Public Member Functions | |
NimBLEUUID ()=default | |
Created a blank UUID. | |
NimBLEUUID (const ble_uuid_any_t &uuid) | |
Create a UUID from the native UUID. | |
NimBLEUUID (const std::string &uuid) | |
Create a UUID from a string. | |
NimBLEUUID (uint16_t uuid) | |
Create a UUID from the 16bit value. | |
NimBLEUUID (uint32_t uuid) | |
Create a UUID from the 32bit value. | |
NimBLEUUID (const ble_uuid128_t *uuid) | |
Create a UUID from the native UUID. | |
NimBLEUUID (const uint8_t *pData, size_t size) | |
Create a UUID from 2, 4, 16 bytes of memory. | |
NimBLEUUID (uint32_t first, uint16_t second, uint16_t third, uint64_t fourth) | |
Create a UUID from the 128bit value using hex parts instead of string, instead of NimBLEUUID("ebe0ccb0-7a0a-4b0c-8a1a-6ff2997da3a6"), it becomes NimBLEUUID(0xebe0ccb0, 0x7a0a, 0x4b0c, 0x8a1a6ff2997da3a6) | |
uint8_t | bitSize () const |
Get the bit size of the UUID, 16, 32 or 128. | |
const uint8_t * | getValue () const |
Get the uuid value. | |
const ble_uuid_t * | getBase () const |
Get a pointer to the NimBLE UUID base structure. | |
bool | equals (const NimBLEUUID &uuid) const |
Compare a UUID against this UUID. | |
std::string | toString () const |
Get a string representation of the UUID. | |
const NimBLEUUID & | to128 () |
Convert a UUID to its 128 bit representation. | |
const NimBLEUUID & | to16 () |
Convert 128 bit UUID to its 16 bit representation. | |
const NimBLEUUID & | reverseByteOrder () |
Reverse the byte order of the UUID. | |
bool | operator== (const NimBLEUUID &rhs) const |
Convenience operator to check if this UUID is equal to another. | |
bool | operator!= (const NimBLEUUID &rhs) const |
Convenience operator to check if this UUID is not equal to another. | |
operator std::string () const | |
Convenience operator to convert this UUID to string representation. | |
Static Public Member Functions | |
static NimBLEUUID | fromString (const std::string &uuid) |
A model of a BLE UUID.
NimBLEUUID::NimBLEUUID | ( | const ble_uuid_any_t & | uuid | ) |
Create a UUID from the native UUID.
[in] | uuid | The native UUID. |
NimBLEUUID::NimBLEUUID | ( | const std::string & | value | ) |
Create a UUID from a string.
Create a UUID from a string. There will be two possible stories here. Either the string represents a binary data field or the string represents a hex encoding of a UUID. For the hex encoding, here is an example:
This has a length of 36 characters. We need to parse this into 16 bytes.
[in] | value | The string to build a UUID from. |
NimBLEUUID::NimBLEUUID | ( | uint16_t | uuid | ) |
Create a UUID from the 16bit value.
[in] | uuid | The 16bit short form UUID. |
NimBLEUUID::NimBLEUUID | ( | uint32_t | uuid | ) |
Create a UUID from the 32bit value.
[in] | uuid | The 32bit short form UUID. |
NimBLEUUID::NimBLEUUID | ( | const ble_uuid128_t * | uuid | ) |
Create a UUID from the native UUID.
[in] | uuid | The native UUID. |
NimBLEUUID::NimBLEUUID | ( | const uint8_t * | pData, |
size_t | size | ||
) |
Create a UUID from 2, 4, 16 bytes of memory.
[in] | pData | The pointer to the start of the UUID. |
[in] | size | The size of the data. |
NimBLEUUID::NimBLEUUID | ( | uint32_t | first, |
uint16_t | second, | ||
uint16_t | third, | ||
uint64_t | fourth | ||
) |
Create a UUID from the 128bit value using hex parts instead of string, instead of NimBLEUUID("ebe0ccb0-7a0a-4b0c-8a1a-6ff2997da3a6"), it becomes NimBLEUUID(0xebe0ccb0, 0x7a0a, 0x4b0c, 0x8a1a6ff2997da3a6)
[in] | first | The first 32bit of the UUID. |
[in] | second | The next 16bit of the UUID. |
[in] | third | The next 16bit of the UUID. |
[in] | fourth | The last 64bit of the UUID, combining the last 2 parts of the string equivalent |
uint8_t NimBLEUUID::bitSize | ( | ) | const |
Get the bit size of the UUID, 16, 32 or 128.
bool NimBLEUUID::equals | ( | const NimBLEUUID & | uuid | ) | const |
Compare a UUID against this UUID.
[in] | uuid | The UUID to compare against. |
|
static |
Create a NimBLEUUID from a string of the form: 0xNNNN 0xNNNNNNNN 0x<UUID> NNNN NNNNNNNN <UUID>
[in] | uuid | The string to create the UUID from. |
const ble_uuid_t * NimBLEUUID::getBase | ( | ) | const |
Get a pointer to the NimBLE UUID base structure.
const uint8_t * NimBLEUUID::getValue | ( | ) | const |
Get the uuid value.
bitSize()
before accessing. NimBLEUUID::operator std::string | ( | ) | const |
Convenience operator to convert this UUID to string representation.
This allows passing NimBLEUUID to functions that accept std::string and/or or it's methods as a parameter.
const NimBLEUUID & NimBLEUUID::reverseByteOrder | ( | ) |
Reverse the byte order of the UUID.
This is useful when comparing UUIDs or when the advertisement data is reversed.
const NimBLEUUID & NimBLEUUID::to128 | ( | ) |
Convert a UUID to its 128 bit representation.
A UUID can be internally represented as 16bit, 32bit or the full 128bit. This method will convert 16 or 32bit representations to the full 128bit.
const NimBLEUUID & NimBLEUUID::to16 | ( | ) |
Convert 128 bit UUID to its 16 bit representation.
A UUID can be internally represented as 16bit, 32bit or the full 128bit. This method will convert a 128bit uuid to 16bit if it contains the ble base uuid.
std::string NimBLEUUID::toString | ( | ) | const |
Get a string representation of the UUID.
The format of a string is: 01234567 8901 2345 6789 012345678901 0000180d-0000-1000-8000-00805f9b34fb 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5