|
| 1 | +.. _lib_ble_queued_writes: |
| 2 | + |
| 3 | +Bluetooth: Queued Writes |
| 4 | +######################## |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +The Bluetooth Low Energy® queued writes library provides an implementation of Queued Writes. |
| 11 | + |
| 12 | +Overview |
| 13 | +******** |
| 14 | + |
| 15 | +Writing to a GATT characteristic can be done in a single write command or in a series of commands. |
| 16 | +Splitting the write operation into several commands makes it possible to write attribute values that are longer than a single packet. |
| 17 | +Such a series of write commands, called a Queued Write operation, consists of multiple prepare write commands followed by one execute write command. |
| 18 | + |
| 19 | +The Queued Writes module provides an implementation of Queued Writes, using the Generic Attribute Profile (GATT) Server interface of the SoftDevice. |
| 20 | +Add this module to your GATT server implementation to enable support for Queued Writes for some or all of the characteristics. |
| 21 | +A GATT client can then write to these characteristics using a series of commands. |
| 22 | + |
| 23 | +Configuration |
| 24 | +************* |
| 25 | + |
| 26 | +The library is enabled and configured using the Kconfig system. |
| 27 | +Set the :kconfig:option:`CONFIG_BLE_QWR` Kconfig option to enable the library. |
| 28 | + |
| 29 | +The :kconfig:option:`CONFIG_BLE_QWR_MAX_ATTR` Kconfig option sets the maximum number of attributes that can be handled by the queued writes library. |
| 30 | + |
| 31 | +Initialization |
| 32 | +============== |
| 33 | + |
| 34 | +To initialize an instance of the module, call the :c:func:`ble_qwr_init` function. |
| 35 | +You must provide an configuration structure that minimum contains an event handler. |
| 36 | +For supporting Queued Writes operations, a buffer for storing the received data must be provided as part of the configuration. |
| 37 | +If the buffer is not provided, the library will reject all Queued Writes requests. |
| 38 | +Next, call the :c:func:`ble_qwr_attr_register` function repeatedly to register each characteristic attribute for which you want to enable Queued Writes. |
| 39 | +Attributes are identified by their handles. |
| 40 | + |
| 41 | +Usage |
| 42 | +***** |
| 43 | + |
| 44 | +The callback function is used to authorize the write requests. |
| 45 | +When the module receives an execute write request, it calls the callback function with an :c:enum:`BLE_QWR_EVT_AUTH_REQUEST` event to determine whether the request should be accepted: |
| 46 | + |
| 47 | +* To authorize the request, the callback function must return :c:macro:`BLE_GATT_STATUS_SUCCESS`. |
| 48 | + 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 :c:enum:`BLE_QWR_EVT_EXECUTE_WRITE` event. |
| 49 | +* 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 :c:macro:`BLE_GATT_STATUS_SUCCESS`. |
| 50 | + The module then deletes the received data. |
| 51 | + |
| 52 | +Dependencies |
| 53 | +************ |
| 54 | + |
| 55 | +This library uses the following |BMshort| libraries: |
| 56 | + |
| 57 | +* SoftDevice - :kconfig:option:`CONFIG_SOFTDEVICE` |
| 58 | +* SoftDevice handler - :kconfig:option:`CONFIG_NRF_SDH` |
| 59 | + |
| 60 | +API documentation |
| 61 | +***************** |
| 62 | + |
| 63 | +| Header file: :file:`include/ble_qwr.h` |
| 64 | +| Source files: :file:`lib/ble_qwr/` |
| 65 | +
|
| 66 | +:ref:`Bluetooth LE Queued Writes library API reference <api_queued_writes>` |
0 commit comments