|
| 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 handle them at the moment. |
| 11 | + |
| 12 | +Overview |
| 13 | +******** |
| 14 | + |
| 15 | +If the SoftDevice is not able to handle the GATT request at the moment, the BLE GATT Queue library buffers the request. |
| 16 | +Later on, when the corresponding BLE event indicates that the SoftDevice may be free, the request is retried. |
| 17 | +This library can be used in multiple connections scenario. |
| 18 | + |
| 19 | +The library can currently handle 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 BLE GATT Queue can be used with BLE service clients and other BLE 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 | +If you need an instance that does not use the default parameters, it can be added with 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 simultaneous connections the GATT queue instance can manage. |
| 42 | +* :kconfig:option:`CONFIG_BLE_GQ_QUEUE_SIZE` - Sets the max number of requests that can be queued for each connection that have 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 | + |
| 45 | +Initialization |
| 46 | +============== |
| 47 | + |
| 48 | +The module does not require other reqistration than adding the library instance as described above. |
| 49 | + |
| 50 | +Usage |
| 51 | +***** |
| 52 | + |
| 53 | +Once defined, you can register a connection handle in the BLE Gatt Queue (BLE GQ) instance by calling the :c:func:`ble_gq_conn_handle_register` function. |
| 54 | +From this point forward, the BLE GQ instance can handle GATT requests associated with the handle until the connection is no longer valid (for example when a disconnect event occurs). |
| 55 | + |
| 56 | +To add a GATT request to the BLE GQ instance, call the :c:func:`ble_gq_item_add` function. |
| 57 | +This function adds a request to the BLE GQ instance and allocates the necessary memory for data that can be held within the request descriptor. |
| 58 | +If the SoftDevice is free, this request will be processed immediately. |
| 59 | +Otherwise, the request remains in the queue and is processed later. |
| 60 | + |
| 61 | +Dependencies |
| 62 | +************ |
| 63 | + |
| 64 | +This library uses the following |BMshort| libraries: |
| 65 | + |
| 66 | +* SoftDevice - :kconfig:option:`CONFIG_SOFTDEVICE` |
| 67 | +* SoftDevice handler - :kconfig:option:`CONFIG_NRF_SDH` |
| 68 | + |
| 69 | +API documentation |
| 70 | +***************** |
| 71 | + |
| 72 | +| Header file: :file:`include/ble_gatt_queue.h` |
| 73 | +| Source files: :file:`lib/ble_gatt_queue/` |
| 74 | +
|
| 75 | +:ref:`Bluetooth LE GATT Queue library API reference <api_ble_gatt_queue>` |
0 commit comments