| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
Queued Writes module
BLE libraries

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

enum nrf_ble_qwr_evt_type_t

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_qwr | Queued Writes structure.
  [in] | attr_handle | Handle of the attribute to register.

Return values

  NRF_SUCCESS | If the registration was successful.
  NRF_ERROR_NO_MEM | If no more memory is available to add this registration.
  NRF_ERROR_NULL | If any of the given pointers is NULL.
  NRF_ERROR_INVALID_STATE | If 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_qwr | Queued Writes structure.
  [in] | conn_handle | Connection handle to be associated with the given Queued Writes instance.

Return values

  NRF_SUCCESS | If the assignment was successful.
  NRF_ERROR_NULL | If any of the given pointers is NULL.
  NRF_ERROR_INVALID_STATE | If 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_qwr | Queued 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_init | Initialization structure.

Return values

  NRF_SUCCESS | If the Queued Writes module was initialized successfully.
  NRF_ERROR_NULL | If any of the given pointers is NULL.
  NRF_ERROR_INVALID_STATE | If 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_qwr | Queued Writes structure.
  [in] | p_ble_evt | Event 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_qwr | Queued Writes structure.
  [in] | attr_handle | Handle of the attribute.
  [out] | p_mem | Pointer to the application buffer where the received data will be copied.
  [in,out] | p_len | Input: length of the input buffer. Output: length of the received data.

Return values

  NRF_SUCCESS | If the data was retrieved and stored successfully.
  NRF_ERROR_NO_MEM | If the provided buffer was smaller than the received data.
  NRF_ERROR_NULL | If any of the given pointers is NULL.
  NRF_ERROR_INVALID_STATE | If the given context has not been initialized.