nRF5 SDK  v13.0.0
Choose documentation:
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Queued Writes
This information applies to the following SoftDevices: S132, S140

Writing to a GATT characteristic can be done in a single write command or in a series of commands. Splitting the write operation into several commands makes it possible to write attribute values that are longer than a single packet. Such a series of write commands, called a Queued Write operation, consists of multiple prepare write commands followed by one execute write command.

The Queued Writes module provides an implementation of Queued Writes, using the Generic Attribute Profile (GATT) Server interface of the SoftDevice. Add this module to your GATT server implementation to enable support for Queued Writes for some or all of the characteristics. A GATT client can then write to these characteristics using a series of commands.

To initialize an instance of the module, call the nrf_ble_qwr_init function. You must provide an initialization structure that contains an error handler, a buffer for storing the received data, and a callback function. Next, call nrf_ble_qwr_attr_register repeatedly to register each characteristic attribute for which you want to enable Queued Writes. Attributes are identified by their handles.

The callback function is used to authorize write requests. When the module receives an execute write request, it calls the callback function with an NRF_BLE_QWR_EVT_AUTH_REQUEST event to determine whether the request should be accepted:

  • To authorize the request, the callback function must return BLE_GATT_STATUS_SUCCESS. The module then writes all received data and notifies the GATT server that the data is ready to use by calling the callback function again, this time with an NRF_BLE_QWR_EVT_EXECUTE_WRITE event.
  • To reject the request (for example, because the received data is not valid or the application is busy), the callback function must return a BLE GATT status code other than BLE_GATT_STATUS_SUCCESS. The module then deletes the received data.