Queue for the BLE GATT requests. More...
Modules | |
BLE GATT Queue Module configuration | |
Data Structures | |
struct | nrf_ble_gq_gattc_read_t |
Structure used to describe NRF_BLE_GQ_REQ_GATTC_READ request type. More... | |
struct | nrf_ble_gq_gattc_srv_discovery_t |
Structure used to describe NRF_BLE_GQ_REQ_SRV_DISCOVERY request type. More... | |
struct | nrf_ble_gq_req_error_handler_t |
Structure used to handle SoftDevice error. More... | |
struct | nrf_ble_gq_req_t |
Structure used to describe BLE GATT request. More... | |
struct | nrf_ble_gq_t |
Descriptor for the BLE GATT Queue instance. More... | |
Macros | |
#define | NRF_BLE_GQ_DEF(_name, _max_connections, _queue_size) |
Macro for defining a nrf_ble_gq_t instance with default parameters. More... | |
#define | NRF_BLE_GQ_CUSTOM_DEF(_name, _max_connections, _queue_size, _pool_elem_size, _pool_elem_count) |
Macro for defining a nrf_ble_gq_t instance. More... | |
#define | NRF_BLE_GQ_CONN_HANDLE_INIT(_arg) BLE_CONN_HANDLE_INVALID, |
Helping macro used to properly initialize connection handle array for nrf_ble_gq_t instance. Used in NRF_BLE_GQ_CUSTOM_DEF. | |
Typedefs | |
typedef void(* | nrf_ble_gq_req_error_cb_t )(uint32_t nrf_error, void *p_context, uint16_t conn_handle) |
Pointer used to describe error handler for GATTC request. | |
typedef ble_gattc_write_params_t | nrf_ble_gq_gattc_write_t |
Structure used to describe NRF_BLE_GQ_REQ_GATTC_WRITE request type. | |
typedef ble_gattc_handle_range_t | nrf_ble_gq_gattc_char_disc_t |
Structure used to describe NRF_BLE_GQ_REQ_CHAR_DISCOVERY request type. | |
typedef ble_gattc_handle_range_t | nrf_ble_gq_gattc_desc_disc_t |
Structure used to describe NRF_BLE_GQ_REQ_DESC_DISCOVERY request type. | |
typedef ble_gatts_hvx_params_t | nrf_ble_gq_gatts_hvx_t |
Structure used to describe NRF_BLE_GQ_REQ_GATTS_HVX request type. | |
Enumerations | |
enum | nrf_ble_gq_req_type_t { NRF_BLE_GQ_REQ_GATTC_READ, NRF_BLE_GQ_REQ_GATTC_WRITE, NRF_BLE_GQ_REQ_SRV_DISCOVERY, NRF_BLE_GQ_REQ_CHAR_DISCOVERY, NRF_BLE_GQ_REQ_DESC_DISCOVERY, NRF_BLE_GQ_REQ_GATTS_HVX, NRF_BLE_GQ_REQ_NUM } |
BLE GATT request types. More... | |
Functions | |
ret_code_t | nrf_ble_gq_item_add (nrf_ble_gq_t const *const p_gatt_queue, nrf_ble_gq_req_t *const p_req, uint16_t conn_handle) |
Function for adding a GATT request to the BGQ instance. More... | |
ret_code_t | nrf_ble_gq_conn_handle_register (nrf_ble_gq_t *const p_gatt_queue, uint16_t conn_handle) |
Function for registering connection handle in the BGQ instance. More... | |
void | nrf_ble_gq_on_ble_evt (ble_evt_t const *p_ble_evt, void *p_context) |
Function for handling BLE events from the SoftDevice. More... | |
Queue for the BLE GATT requests.
The BLE GATT Queue (BGQ) module can be used to queue BLE GATT requests if the SoftDevice is not able to handle them at the moment. In this case, processing of queued request is postponed. Later on, when corresponding BLE event indicates that the SoftDevice may be free, the request is retried. For conceptual documentation of this module, see BLE GATT Queue.
#define NRF_BLE_GQ_CUSTOM_DEF | ( | _name, | |
_max_connections, | |||
_queue_size, | |||
_pool_elem_size, | |||
_pool_elem_count | |||
) |
Macro for defining a nrf_ble_gq_t instance.
_name | Name of the instance. |
_max_connections | The maximal number of connection handles that can be registered. |
_queue_size | The maximal number of nrf_ble_gq_req_t instances that queue can hold. |
_pool_elem_size | Size of a single element in the pool of memory objects. |
_pool_elem_count | Number of elements in the pool of memory objects. |
#define NRF_BLE_GQ_DEF | ( | _name, | |
_max_connections, | |||
_queue_size | |||
) |
Macro for defining a nrf_ble_gq_t instance with default parameters.
_name | Name of the instance. |
_max_connections | The maximal number of connection handles that can be registered. |
_queue_size | The maximal number of nrf_ble_gq_req_t instances that queue can hold. |
BLE GATT request types.
Enumerator | |
---|---|
NRF_BLE_GQ_REQ_GATTC_READ |
GATTC Read Request. See nrf_ble_gq_gattc_read_t and sd_ble_gattc_read |
NRF_BLE_GQ_REQ_GATTC_WRITE |
GATTC Write Request. See nrf_ble_gq_gattc_write_t and sd_ble_gattc_write |
NRF_BLE_GQ_REQ_SRV_DISCOVERY |
GATTC Service Discovery Request. See nrf_ble_gq_gattc_write_t and sd_ble_gattc_primary_services_discover. |
NRF_BLE_GQ_REQ_CHAR_DISCOVERY |
GATTC Characteristic Discovery Request. See nrf_ble_gq_gattc_char_disc_t and sd_ble_gattc_characteristics_discover. |
NRF_BLE_GQ_REQ_DESC_DISCOVERY |
GATTC Characteristic Descriptor Discovery Request. See nrf_ble_gq_gattc_desc_disc_t and sd_ble_gattc_descriptors_discover |
NRF_BLE_GQ_REQ_GATTS_HVX |
GATTS Handle Value Notification or Indication. See nrf_ble_gq_gatts_hvx_t and ble_gatts_hvx_params_t |
NRF_BLE_GQ_REQ_NUM |
Total number of different GATT Request types |
ret_code_t nrf_ble_gq_conn_handle_register | ( | nrf_ble_gq_t *const | p_gatt_queue, |
uint16_t | conn_handle | ||
) |
Function for registering connection handle in the BGQ instance.
This function is used for registering connection handle in the BGQ instance. From this point, the BGQ instance can handle GATT requests associated with the handle until connection is no longer valid (disconnect event occurs).
[in] | p_gatt_queue | Pointer to the BGQ instance. |
[in] | conn_handle | Connection handle. |
NRF_SUCCESS | If the registration was successful. |
NRF_ERROR_NULL | If p_gatt_queue was NULL. |
NRF_ERROR_NO_MEM | If there was no space for another connection handle. |
ret_code_t nrf_ble_gq_item_add | ( | nrf_ble_gq_t const *const | p_gatt_queue, |
nrf_ble_gq_req_t *const | p_req, | ||
uint16_t | conn_handle | ||
) |
Function for adding a GATT request to the BGQ instance.
This function adds a request to the BGQ instance and allocates necessary memory for data that can be held within the request descriptor. If the SoftDevice is free, this request will be processed immediately. Otherwise, the request remains in in the queue and is processed later.
[in] | p_gatt_queue | Pointer to the BGQ instance. |
[in] | p_req | Pointer to the request. |
[in] | conn_handle | Connection handle associated with the request. |
NRF_SUCCESS | If the request was added successfully. |
NRF_ERROR_NULL | Any parameter was NULL. |
NRF_ERROR_NO_MEM | There was no room in the queue or in the data pool. |
NRF_ERROR_INVALID_PARAM | If conn_handle is not registered or type of request - p_req is not valid. |
err_code | Other request specific error codes may be returned. |
void nrf_ble_gq_on_ble_evt | ( | ble_evt_t const * | p_ble_evt, |
void * | p_context | ||
) |
Function for handling BLE events from the SoftDevice.
This function handles the BLE events received from the SoftDevice. If a BLE event is relevant to the BGQ module, it is used to update internal variables, process queued GATT requests and, if necessary, send errors to the application.
[in] | p_ble_evt | Pointer to the BLE event. |
[in] | p_context | Pointer to the BGQ instance. |