nRF5 SDK v12.1.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
Queued Writes module

Module for handling Queued Write operations. More...

Modules

 Queued writes support module (prepare/execute write) configuration
 

Data Structures

struct  nrf_ble_qwr_evt_t
 Queued Writes module events. More...
 
struct  nrf_ble_qwr_t
 Queued Writes structure. More...
 
struct  nrf_ble_qwr_init_t
 Queued Writes init structure. More...
 

Macros

#define NRF_BLE_QUEUED_WRITES_H__
 
#define NRF_BLE_QWR_ATTR_LIST_SIZE   10
 Maximum number of attribute handles that can be registered. This number must be adjusted according to the number of attributes for which Queued Writes will be enabled.
 
#define NRF_BLE_QWR_REJ_REQUEST_ERR_CODE   BLE_GATT_STATUS_ATTERR_APP_BEGIN + 0
 Error code used by the module to reject prepare write requests on non-registered attributes.
 

Typedefs

typedef uint16_t(* nrf_ble_qwr_evt_handler_t )(struct nrf_ble_qwr_t *p_qwr, nrf_ble_qwr_evt_t *p_evt)
 Queued Writes module event handler type. More...
 
typedef struct nrf_ble_qwr_t nrf_ble_qwr_t
 Queued Writes structure. More...
 

Enumerations

enum  nrf_ble_qwr_evt_type_t {
  NRF_BLE_QWR_EVT_EXECUTE_WRITE,
  NRF_BLE_QWR_EVT_AUTH_REQUEST
}
 Queued Writes module event types. More...
 

Functions

ret_code_t nrf_ble_qwr_init (nrf_ble_qwr_t *p_qwr, nrf_ble_qwr_init_t const *p_qwr_init)
 Function for initializing the Queued Writes module. More...
 
ret_code_t nrf_ble_qwr_attr_register (nrf_ble_qwr_t *p_qwr, uint16_t attr_handle)
 Function for registering an attribute with the Queued Writes module. More...
 
void nrf_ble_qwr_on_ble_evt (nrf_ble_qwr_t *p_qwr, ble_evt_t *p_ble_evt)
 Function for handling BLE stack events. More...
 
ret_code_t nrf_ble_qwr_value_get (nrf_ble_qwr_t *p_qwr, uint16_t attr_handle, uint8_t *p_mem, uint16_t *p_len)
 Function for retrieving the received data for a given attribute. More...
 
ret_code_t nrf_ble_qwr_conn_handle_assign (nrf_ble_qwr_t *p_qwr, uint16_t conn_handle)
 Function for assigning a connection handle to a given instance of the Queued Writes module. More...
 

Detailed Description

Module for handling Queued Write operations.

This module handles prepare write, execute write, and cancel write commands. It also manages memory requests related to these operations.

Note
The application must propagate BLE stack events to this module by calling nrf_ble_qwr_on_ble_evt().

Typedef Documentation

typedef uint16_t(* nrf_ble_qwr_evt_handler_t)(struct nrf_ble_qwr_t *p_qwr, nrf_ble_qwr_evt_t *p_evt)

Queued Writes module event handler type.

If the provided event is of type NRF_BLE_QWR_EVT_AUTH_REQUEST, this function must accept or reject the execute write request by returning one of the GATT Status Codes.

typedef struct nrf_ble_qwr_t nrf_ble_qwr_t

Queued Writes structure.

This structure contains status information for the Queued Writes module.

Enumeration Type Documentation

Queued Writes module event types.

Enumerator
NRF_BLE_QWR_EVT_EXECUTE_WRITE 

Event that indicates that an execute write command was received for a registered handle and that the received data was actually written and is now ready.

NRF_BLE_QWR_EVT_AUTH_REQUEST 

Event that indicates that an execute write command was received for a registered handle and that the write request must now be accepted or rejected.

Function Documentation

ret_code_t nrf_ble_qwr_attr_register ( nrf_ble_qwr_t p_qwr,
uint16_t  attr_handle 
)

Function for registering an attribute with the Queued Writes module.

Call this function for each attribute that you want to enable for Queued Writes (thus a series of prepare write and execute write operations).

Parameters
[in]p_qwrQueued Writes structure.
[in]attr_handleHandle of the attribute to register.
Return values
NRF_SUCCESSIf the registration was successful.
NRF_ERROR_NO_MEMIf no more memory is available to add this registration.
NRF_ERROR_NULLIf any of the given pointers is NULL.
NRF_ERROR_INVALID_STATEIf the given context has not been initialized.
ret_code_t nrf_ble_qwr_conn_handle_assign ( nrf_ble_qwr_t p_qwr,
uint16_t  conn_handle 
)

Function for assigning a connection handle to a given instance of the Queued Writes module.

Call this function when a link with a peer has been established to associate this link to the instance of the module. This makes it possible to handle several links and associate each link to a particular instance of this module.

Parameters
[in]p_qwrQueued Writes structure.
[in]conn_handleConnection handle to be associated with the given Queued Writes instance.
Return values
NRF_SUCCESSIf the assignment was successful.
NRF_ERROR_NULLIf any of the given pointers is NULL.
NRF_ERROR_INVALID_STATEIf the given context has not been initialized.
ret_code_t nrf_ble_qwr_init ( nrf_ble_qwr_t p_qwr,
nrf_ble_qwr_init_t const *  p_qwr_init 
)

Function for initializing the Queued Writes module.

Call this function in the main entry of your application to initialize the Queued Writes module. It must be called only once with a given Queued Writes structure.

Parameters
[out]p_qwrQueued Writes structure. This structure must be supplied by the application. It is initialized by this function and is later used to identify the particular Queued Writes instance.
[in]p_qwr_initInitialization structure.
Return values
NRF_SUCCESSIf the Queued Writes module was initialized successfully.
NRF_ERROR_NULLIf any of the given pointers is NULL.
NRF_ERROR_INVALID_STATEIf the given context has already been initialized.
void nrf_ble_qwr_on_ble_evt ( nrf_ble_qwr_t p_qwr,
ble_evt_t p_ble_evt 
)

Function for handling BLE stack events.

Handles all events from the BLE stack that are of interest to the Queued Writes module.

Parameters
[in]p_qwrQueued Writes structure.
[in]p_ble_evtEvent received from the BLE stack.
ret_code_t nrf_ble_qwr_value_get ( nrf_ble_qwr_t p_qwr,
uint16_t  attr_handle,
uint8_t *  p_mem,
uint16_t *  p_len 
)

Function for retrieving the received data for a given attribute.

Call this function after receiving an NRF_BLE_QWR_EVT_AUTH_REQUEST event to retrieve a linear copy of the data that was received for the given attribute.

Parameters
[in]p_qwrQueued Writes structure.
[in]attr_handleHandle of the attribute.
[out]p_memPointer to the application buffer where the received data will be copied.
[in,out]p_lenInput: length of the input buffer. Output: length of the received data.
Return values
NRF_SUCCESSIf the data was retrieved and stored successfully.
NRF_ERROR_NO_MEMIf the provided buffer was smaller than the received data.
NRF_ERROR_NULLIf any of the given pointers is NULL.
NRF_ERROR_INVALID_STATEIf the given context has not been initialized.

Documentation feedback | Developer Zone | Subscribe | Updated