What is ble_gattc_handle_range_t?

Hello, I'm seeking some clarification regarding "ble_gattc_handle_range_t". I would like to use the function "sd_ble_gattc_char_value_by_uuid_read()" to read the char value on my peripheral. Is "ble_gattc_handle_range_t" referring to a range of conn_handles or a range of 16bit characteristics, or something else?

`

/**@brief Operation Handle Range. */
typedef struct
{
  uint16_t          start_handle; /**< Start Handle. */
  uint16_t          end_handle;   /**< End Handle. */
} ble_gattc_handle_range_t;

  • Hi,

    Is "ble_gattc_handle_range_t" referring to a range of conn_handles or a range of 16bit characteristics, or something else?

    Something else:

    The ble_gattc_handle_range_t used for p_handle_range in sd_ble_gattc_char_value_by_uuid_read() is the range of GATT table handles for where to look for the characteristic value entry, in the GATT table.

    See the GATTC Read Characteristic Value by UUID Message Sequence Chart for how to use the API. Typically one would start at the full range (0x0001 to 0xFFFF) then if you get one result at e.g. handle 0x000E then you do the next call on the range 0x000F to 0xFFFF.

    Regards,
    Terje

  • Okay thanks. So then "count" in "ble_gattc_evt_char_val_by_uuid_read_rsp_t" would be my "N" right?

    /**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. */
    typedef struct
    {
      uint16_t                  count;            /**< Handle-Value Pair Count. */
      uint16_t                  value_len;        /**< Length of the value in Handle-Value(s) list. */
      uint8_t                   handle_value[1];  /**< Handle-Value(s) list. To iterate through the list use @ref sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter.
                                                       @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
                                                       See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
    } ble_gattc_evt_char_val_by_uuid_read_rsp_t;

  • Could you explain more about the need to change the range? I'm just trying to read a single characteristic / value.

  • Hi,

    If you want to read a single characteristic value, and know which handle the value of this characteristic is stored at, then you only need sd_ble_gattc_read(), which lets you specify the exact handle. If the characteristic value is longer than ATT_MTU - 1, then you must call the function repeatedly with increasing offeset, in order to get the full value.

    The "by_uuid" read is for if you know the UUID of the characteristic, but don't know where in the ATT table it is (what handle, or position, it has in the ATT table.) For that you typically provide a range, since you do not know which of the handles in the range contains your characteristic.

    For more on how services, characteristics and descriptors are stored in the ATT / GATT table, please have a look at Bluetooth low energy Characteristics, a beginner's tutorial. The Attribute Protocol (ATT) section of that tutorial describes this in detail, hopefully enough that after reading it the SoftDevice API should make more sense.

    Regards,
    Terje

Related