BLE Link Context Manager

nRF5 SDK v15.3.0

Storage for link-related data. More...

Data Structures

struct blcm_link_ctx_storage_t
Type of description that is used for registry of all current connections. More...

Macros

#define BLE_LINK_CTX_MANAGER_DEF (_name, _max_clients, _link_ctx_size)
Macro for defining a blcm_link_ctx_storage instance. More...

Functions

ret_code_t blcm_link_ctx_get ( blcm_link_ctx_storage_t const *const p_link_ctx_storage, uint16_t const conn_handle, void **const pp_ctx_data)
Function for getting the link context from the link registry. More...

Detailed Description

Storage for link-related data.

BLE Link Context Manager can be used as a simple storage for link-related data. Each link context data is uniquely identified within the storage by its connection handle and can be retrieved from it by using this handle.

Macro Definition Documentation

#define BLE_LINK_CTX_MANAGER_DEF ( _name,
_max_clients,
_link_ctx_size
)
Value:
static uint32_t CONCAT_2 (_name, _ctx_data_pool)[(_max_clients)* BYTES_TO_WORDS (_link_ctx_size)]; \
static blcm_link_ctx_storage_t _name = \
{ \
. p_ctx_data_pool = CONCAT_2 (_name, _ctx_data_pool), \
.max_links_cnt = (_max_clients), \
.link_ctx_size = sizeof ( CONCAT_2 (_name, _ctx_data_pool))/(_max_clients) \
}

Macro for defining a blcm_link_ctx_storage instance.

Parameters
[in] _name Name of the instance.
[in] _max_clients Maximum number of clients connected at a time.
[in] _link_ctx_size Context size in bytes for a single link.

Function Documentation

ret_code_t blcm_link_ctx_get ( blcm_link_ctx_storage_t const *const p_link_ctx_storage ,
uint16_t const conn_handle ,
void **const pp_ctx_data
)

Function for getting the link context from the link registry.

This function finds the link context in the registry. The link to find is identified by the connection handle within the registry.

The context is preserved for the lifetime of the connection. When a new connection occurs, the value of its context is undefined, and should be initialized.

Parameters
[in] p_link_ctx_storage Pointer to the link storage descriptor.
[in] conn_handle Connection whose context to find.
[out] pp_ctx_data Pointer to data with context for the connection.
Return values
NRF_ERROR_NULL If p_link_ctx_storage is NULL or contains a NULL pointer, or if pp_ctx_data is NULL.
NRF_ERROR_INVALID_PARAM If p_link_ctx_storage::link_ctx_size is not multiple of word size.
NRF_ERROR_NOT_FOUND If conn_handle does not refer to an active or recently disconnected link.
NRF_ERROR_NO_MEM If there is not enough memory to store context for the given connection handle. This can happen if the number of links is greater than p_link_ctx_storage::max_links_cnt .
NRF_SUCCESS If the operation was successful.