Storage for link-related data.
More...
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.
#define BLE_LINK_CTX_MANAGER_DEF |
( |
|
_name, |
|
|
|
_max_clients, |
|
|
|
_link_ctx_size |
|
) |
| |
Value:
{ \
.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 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. |