Bluenet
5.7.0
Bluenet, firmware for nRF52 smart home devices
|
Class that enables the use of 128 bit service UUIDs. More...
#include <cs_UUID.h>
Public Member Functions | |
UUID () | |
Constructor. More... | |
UUID (ble_uuid_t uuid) | |
cs_ret_code_t | fromFullUuid (const char *fullUuid) |
Set UUID from a 128b UUID string. More... | |
cs_ret_code_t | fromFullUuid (const ble_uuid128_t &fullUuid) |
Set UUID from a 128b UUID. More... | |
cs_ret_code_t | fromShortUuid (uint16_t shortUuid) |
Set UUID from a 16b UUID. More... | |
cs_ret_code_t | fromBaseUuid (const UUID &baseUuid, uint16_t shortUuid) |
Set UUID derived from an existing 128b base UUID. More... | |
ble_uuid_t | getUuid () const |
Get the UUID that can be used for soft device operations. More... | |
UUID (const char *fullUuid) | |
Convenience constructors, will crash the firmware instead of returning an error code. More... | |
UUID (uint16_t shortUuid) | |
UUID (const UUID &baseUuid, uint16_t shortUuid) | |
bool | operator== (const UUID &other) |
Private Member Functions | |
ret_code_t | fromShortUuidInternal (uint16_t shortUuid) |
ret_code_t | fromBaseUuidInternal (const UUID &baseUuid, uint16_t shortUuid) |
ret_code_t | fromFullUuidInternal (const ble_uuid128_t &fullUuid) |
ret_code_t | add (const ble_uuid128_t &fullUuid) |
Registers the 128b UUID, without checking if already registered. More... | |
ret_code_t | getFromCache (const ble_uuid128_t &fullUuid) |
Checks if the 128b UUID has been registered, and sets _uuid if so. More... | |
Static Private Member Functions | |
static ret_code_t | rem (const ble_uuid_t &uuid) |
Removes a 128b UUID from the soft device. More... | |
static cs_ret_code_t | fromNrfCode (ret_code_t nrfCode) |
Get the CS return code from an nrf return code. More... | |
Private Attributes | |
ble_uuid_t | _uuid = {.uuid = 0, .type = BLE_UUID_TYPE_UNKNOWN} |
Class that enables the use of 128 bit service UUIDs.
There are predefined 16 bit UUIDs, which can be found here: https://www.bluetooth.com/specifications/assigned-numbers/
Vendor specific UUIDs are usually 128 bit.
128b UUID strings are reverse ordered compared to the byte array, in the form: "15 14 13 12 - 11 10 - 09 08 - 07 06 - 05 04 03 02 01 00" but then without spaces.
The Softdevice functions only deal with 16b UUIDS, so they introduced 1 extra byte (the 'type' field) to indicate the base UUID. This base UUID has to be registered first, but can then be used with different 16b fields. A base UUID would look like XXXX0000-XXXX-XXXX-XXXX-XXXXXXXXXXXX. The 0000 part is then replaced by the 16b UUID.
A typical example is a BLE service with multiple characteristics. All of them will have the same base UUID, but different 16b UUIDs.
TODO: rename to cs_ServiceUuid TODO: maybe change function names "from...." to something else and make clear you can call them multiple times.
UUID::UUID | ( | ) |
Constructor.
UUID::UUID | ( | ble_uuid_t | uuid | ) |
UUID::UUID | ( | const char * | fullUuid | ) |
Convenience constructors, will crash the firmware instead of returning an error code.
UUID::UUID | ( | uint16_t | shortUuid | ) |
UUID::UUID | ( | const UUID & | baseUuid, |
uint16_t | shortUuid | ||
) |
|
private |
Registers the 128b UUID, without checking if already registered.
cs_ret_code_t UUID::fromBaseUuid | ( | const UUID & | baseUuid, |
uint16_t | shortUuid | ||
) |
|
private |
cs_ret_code_t UUID::fromFullUuid | ( | const ble_uuid128_t & | fullUuid | ) |
cs_ret_code_t UUID::fromFullUuid | ( | const char * | fullUuid | ) |
Set UUID from a 128b UUID string.
The 128b UUID will be registered at the soft device.
[in] | fullUuid | In the form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. |
|
private |
|
staticprivate |
Get the CS return code from an nrf return code.
cs_ret_code_t UUID::fromShortUuid | ( | uint16_t | shortUuid | ) |
|
private |
|
private |
Checks if the 128b UUID has been registered, and sets _uuid if so.
ble_uuid_t UUID::getUuid | ( | ) | const |
Get the UUID that can be used for soft device operations.
bool UUID::operator== | ( | const UUID & | other | ) |
|
staticprivate |
Removes a 128b UUID from the soft device.
|
private |