|
| 1 | +.. _lib_ble_gatt_queue: |
| 2 | + |
| 3 | +Bluetooth: GATT Queue |
| 4 | +##################### |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +The Bluetooth Low Energy® GATT Queue library can be used to buffer ``BLE GATT`` requests if the SoftDevice is not able to process them immediately. |
| 11 | + |
| 12 | +Overview |
| 13 | +******** |
| 14 | + |
| 15 | +The GATT Queue library temporarily stores GATT requests if the SoftDevice is currently busy. |
| 16 | +Once the SoftDevice is available, as indicated by a Bluetooth LE event, the library retries the request. |
| 17 | +This library can be used in a multiple connections scenario. |
| 18 | + |
| 19 | +The library currently handles the following types of GATT requests: |
| 20 | + |
| 21 | +* Read Characteristic or Descriptor (see ``sd_ble_gattc_read``). |
| 22 | +* Write Characteristic Value or Descriptor (see ``sd_ble_gattc_write``). |
| 23 | +* Primary Service Discovery (see ``sd_ble_gattc_primary_services_discover``). |
| 24 | +* Characteristic Discovery (see ``sd_ble_gattc_characteristics_discover``). |
| 25 | +* Descriptor Discovery (see ``sd_ble_gattc_descriptors_discover``). |
| 26 | +* Notify or Indicate an attribute value (see ``sd_ble_gatts_hvx``). |
| 27 | + |
| 28 | +The GATT Queue can be used with Bluetooth LE service clients and other Bluetooth LE libraries that issue GATT requests to the SoftDevice. |
| 29 | + |
| 30 | +Configuration |
| 31 | +************* |
| 32 | + |
| 33 | +The library is enabled and configured using the Kconfig system. |
| 34 | +Set the :kconfig:option:`CONFIG_BLE_GATT_QUEUE` Kconfig option to enable the library. |
| 35 | + |
| 36 | +You can add an instance of the library to your application using the :c:macro:`BLE_GQ_DEF` macro. |
| 37 | +To add an instance that does not use the default parameters, use the :c:macro:`BLE_GQ_CUSTOM_DEF` macro. |
| 38 | + |
| 39 | +The library exposes the following Kconfig options for the default configuration: |
| 40 | + |
| 41 | +* :kconfig:option:`CONFIG_BLE_GQ_MAX_CONNECTIONS` - Sets the maximum number of simultaneous connections that the GATT queue instance can manage. |
| 42 | +* :kconfig:option:`CONFIG_BLE_GQ_QUEUE_SIZE` - Sets the maximum number of requests that can be queued for each connection that has been registered to the GATT queue instance. |
| 43 | +* :kconfig:option:`CONFIG_BLE_GQ_HEAP_SIZE` - Sets the heap size for storing additional data that can be of variable size. |
| 44 | + The heap is used for storing the data of Write, Notify, and Indicate requests. |
| 45 | + |
| 46 | +Initialization |
| 47 | +============== |
| 48 | + |
| 49 | +The library does not require other initialization than adding a library instance as described above. |
| 50 | + |
| 51 | +Usage |
| 52 | +***** |
| 53 | + |
| 54 | +After defining a Bluetooth LE Gatt Queue (``BLE GQ``) instance, make sure to register a connection handle by calling the :c:func:`ble_gq_conn_handle_register` function. |
| 55 | +The ``BLE GQ`` instance can now handle GATT requests associated with the handle until the connection is no longer valid (for example, after a disconnect event occurs). |
| 56 | + |
| 57 | +To add a GATT request to the ``BLE GQ`` instance, call the :c:func:`ble_gq_item_add` function. |
| 58 | +This function adds a request to the ``BLE GQ`` instance and allocates necessary memory for the data that can be held within the request descriptor. |
| 59 | +If the SoftDevice is free and the queue is empty, the request is processed immediately. |
| 60 | +Otherwise, the request is queued and processed later. |
| 61 | + |
| 62 | +Dependencies |
| 63 | +************ |
| 64 | + |
| 65 | +This library uses the following |BMshort| libraries: |
| 66 | + |
| 67 | +* SoftDevice - :kconfig:option:`CONFIG_SOFTDEVICE` |
| 68 | +* SoftDevice handler - :kconfig:option:`CONFIG_NRF_SDH` |
| 69 | + |
| 70 | +API documentation |
| 71 | +***************** |
| 72 | + |
| 73 | +| Header file: :file:`include/bm/bluetooth/ble_gq.h` |
| 74 | +| Source files: :file:`lib/bluetooth/ble_gq/` |
| 75 | +
|
| 76 | +:ref:`Bluetooth LE GATT Queue library API reference <api_ble_gatt_queue>` |
0 commit comments