Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
UUID Class Reference

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}
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ UUID() [1/5]

Constructor.

◆ UUID() [2/5]

UUID::UUID ( ble_uuid_t  uuid)

◆ UUID() [3/5]

UUID::UUID ( const char *  fullUuid)

Convenience constructors, will crash the firmware instead of returning an error code.

◆ UUID() [4/5]

UUID::UUID ( uint16_t  shortUuid)

◆ UUID() [5/5]

UUID::UUID ( const UUID baseUuid,
uint16_t  shortUuid 
)

Member Function Documentation

◆ add()

ret_code_t UUID::add ( const ble_uuid128_t &  fullUuid)
private

Registers the 128b UUID, without checking if already registered.

Returns
NRF return code.

◆ fromBaseUuid()

cs_ret_code_t UUID::fromBaseUuid ( const UUID baseUuid,
uint16_t  shortUuid 
)

Set UUID derived from an existing 128b base UUID.

Parameters
[in]baseUuidThe base UUID.
[in]shortUuidReplaces bytes 12 and 13 of the base UUID.

◆ fromBaseUuidInternal()

ret_code_t UUID::fromBaseUuidInternal ( const UUID baseUuid,
uint16_t  shortUuid 
)
private

◆ fromFullUuid() [1/2]

cs_ret_code_t UUID::fromFullUuid ( const ble_uuid128_t &  fullUuid)

Set UUID from a 128b UUID.

The 128b UUID will be registered at the soft device.

Parameters
[in]fullUuidThe 128b UUID.
Returns
ERR_NO_SPACE When there are too many UUIDs registered at the soft device.
ERR_SUCCESS When the UUID was successfully registered at the soft device.

◆ fromFullUuid() [2/2]

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.

Parameters
[in]fullUuidIn the form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
Returns
ERR_NO_SPACE When there are too many UUIDs registered at the soft device.
ERR_SUCCESS When the UUID was successfully registered at the soft device.

◆ fromFullUuidInternal()

ret_code_t UUID::fromFullUuidInternal ( const ble_uuid128_t &  fullUuid)
private

◆ fromNrfCode()

static cs_ret_code_t UUID::fromNrfCode ( ret_code_t  nrfCode)
staticprivate

Get the CS return code from an nrf return code.

◆ fromShortUuid()

cs_ret_code_t UUID::fromShortUuid ( uint16_t  shortUuid)

Set UUID from a 16b UUID.

Parameters
[in]The16b UUID.

◆ fromShortUuidInternal()

ret_code_t UUID::fromShortUuidInternal ( uint16_t  shortUuid)
private

◆ getFromCache()

ret_code_t UUID::getFromCache ( const ble_uuid128_t &  fullUuid)
private

Checks if the 128b UUID has been registered, and sets _uuid if so.

Returns
NRF return code.

◆ getUuid()

ble_uuid_t UUID::getUuid ( ) const

Get the UUID that can be used for soft device operations.

◆ operator==()

bool UUID::operator== ( const UUID other)

◆ rem()

static ret_code_t UUID::rem ( const ble_uuid_t &  uuid)
staticprivate

Removes a 128b UUID from the soft device.

Returns
CS return code.

Member Data Documentation

◆ _uuid

ble_uuid_t UUID::_uuid = {.uuid = 0, .type = BLE_UUID_TYPE_UNKNOWN}
private

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