| 
 | 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 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 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 | +  The heap is used for storing the data of write, notify and indicate requests.  | 
 | 45 | + | 
 | 46 | +Initialization  | 
 | 47 | +==============  | 
 | 48 | + | 
 | 49 | +The module does not require other initialization than adding the library instance as described above.  | 
 | 50 | + | 
 | 51 | +Usage  | 
 | 52 | +*****  | 
 | 53 | + | 
 | 54 | +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.  | 
 | 55 | +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).  | 
 | 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 the necessary memory for data that can be held within the request descriptor.  | 
 | 59 | +If the SoftDevice is free and the queue is empty, the request will be 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/ble_gq.h`  | 
 | 74 | +| Source files: :file:`lib/ble_gq/`  | 
 | 75 | +
  | 
 | 76 | +:ref:`Bluetooth LE GATT Queue library API reference <api_ble_gatt_queue>`  | 
0 commit comments