Functions
Functions
BLE » Generic Attribute Profile (GATT) » Generic Attribute Profile (GATT) Client

## Functions
uint16_t | ble_gattc_mtu_exchange (uint8_t conn_idx)
| Perform MTU Exchange. More...
uint16_t | ble_gattc_services_browse (uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid)
| Browse all Primary Services or specific Primary Service information on remote GATT server. More...
uint16_t | ble_gattc_primary_services_discover (uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid)
| Discover Primary Services on remote GATT server. More...
uint16_t | ble_gattc_included_services_discover (uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl)
| Discover Included Services on remote GATT server. More...
uint16_t | ble_gattc_char_discover (uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl, const ble_uuid_t *p_char_uuid)
| Discover Characteristics on remote GATT server. More...
uint16_t | ble_gattc_char_desc_discover (uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl)
| Discover Characteristics Descriptors on remote GATT server. More...
uint16_t | ble_gattc_read (uint8_t conn_idx, uint16_t handle, uint16_t offset)
| Read Attribute from remote GATT server. More...
uint16_t | ble_gattc_read_by_uuid (uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl, const ble_uuid_t *p_char_uuid)
| Read Attribute by UUID. More...
uint16_t | ble_gattc_read_multiple (uint8_t conn_idx, const gattc_read_multiple_t *p_param)
| Initiate a Read Multiple Characteristic Values procedure. More...
uint16_t | ble_gattc_write (uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value)
| Write (long) Characteristic (Descriptor) Value. More...
uint16_t | ble_gattc_write_prepare (uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value)
| Prepare Long/Reliable Write to remote GATT server. More...
uint16_t | ble_gattc_write_execute (uint8_t conn_idx, bool execute)
| Execute Reliable/Long Write to remote GATT server. More...
uint16_t | ble_gattc_write_no_resp (uint8_t conn_idx, bool signed_write, uint16_t handle, uint16_t length, const uint8_t *p_value)
| Write Attribute to remote GATT server (without response). More...
uint16_t | ble_gattc_indicate_cfm (uint8_t conn_idx, uint16_t handle)
| Confirm Reception of Indication. More...

## Detailed Description

## Function Documentation

## ◆ ble_gattc_char_desc_discover()

uint16_t ble_gattc_char_desc_discover | ( | uint8_t | conn_idx,
|  | uint16_t | start_hdl,
|  | uint16_t | end_hdl
| ) |  |

Discover Characteristics Descriptors on remote GATT server.

Note
  Function callback gattc_cb_fun_t::app_gattc_char_desc_disc_cb will be called for Characteristic Descriptor(s) found.
  If the last Descriptor has not been reached, this function must be called again with an updated handle range to continue the discovery.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | start_hdl | Start handle.
  [in] | end_hdl | End handle.

Return values

  SDK_SUCCESS | Successfully start the Descriptor Discovery procedure.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_char_discover()

uint16_t ble_gattc_char_discover | ( | uint8_t | conn_idx,
|  | uint16_t | start_hdl,
|  | uint16_t | end_hdl,
|  | const ble_uuid_t * | p_char_uuid
| ) |  |

Discover Characteristics on remote GATT server.

Note
  Function callback gattc_cb_fun_t::app_gattc_char_disc_cb will be called for Characteristic Declaration(s) found.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | start_hdl | Start handle.
  [in] | end_hdl | End handle.
  [in] | p_char_uuid | Pointer to Characteristic UUID.If it is NULL, all characteristics are returned.

Return values

  SDK_SUCCESS | Successfully start the Characteristic Discovery procedure.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_included_services_discover()

uint16_t ble_gattc_included_services_discover | ( | uint8_t | conn_idx,
|  | uint16_t | start_hdl,
|  | uint16_t | end_hdl
| ) |  |

Discover Included Services on remote GATT server.

Note
  Function callback gattc_cb_fun_t::app_gattc_inc_srvc_disc_cb will be called for Included Service(s) found.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | start_hdl | Start handle.
  [in] | end_hdl | End handle.

Return values

  SDK_SUCCESS | Successfully start the Relationship Discovery procedure.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_indicate_cfm()

uint16_t ble_gattc_indicate_cfm | ( | uint8_t | conn_idx,
|  | uint16_t | handle
| ) |  |

Confirm Reception of Indication.

Note
  Confirm indication which has been correctly received from the peer.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | handle | Value handle.

Return values

  SDK_SUCCESS | Successfully send indication confirm.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_mtu_exchange()

uint16_t ble_gattc_mtu_exchange | ( | uint8_t | conn_idx | ) |

Perform MTU Exchange.

Note
  MTU Exchange Callback gatt_common_cb_fun_t::app_gatt_mtu_exchange_cb will be called to indicate to APP once receiving the peer response.

Parameters

  [in] | conn_idx | Current connection index.

Return values

  SDK_SUCCESS | Successfully send an MTU Exchange request.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_primary_services_discover()

uint16_t ble_gattc_primary_services_discover | ( | uint8_t | conn_idx,
|  | const ble_uuid_t * | p_srvc_uuid
| ) |  |

Discover Primary Services on remote GATT server.

Note
  Function callback gattc_cb_fun_t::app_gattc_srvc_disc_cb will be called for service(s) found.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | p_srvc_uuid | Pointer to Service UUID. If it is NULL, all Primary Services will be returned.

Return values

  SDK_SUCCESS | Successfully start the Primary Service Discovery procedure.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_read()

uint16_t ble_gattc_read | ( | uint8_t | conn_idx,
|  | uint16_t | handle,
|  | uint16_t | offset
| ) |  |

Read Attribute from remote GATT server.

Note
  This uses either the "Read Characteristic Value" procedure or the "Read Characteristic Descriptor" procedure, depending on the attribute pointed by handle. If offset is non-zero or the attribute length is larger than the MTU, the "Read Long Characteristic Value" procedure or the "Read Long Characteristic Descriptor" procedure will be used respectively.
  Function callback gattc_cb_fun_t::app_gattc_read_cb will be called when Read is finished.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | handle | Attribute handle.
  [in] | offset | Value offset to start with.

Return values

  SDK_SUCCESS | Successfully start the Read (Long) procedure.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_read_by_uuid()

uint16_t ble_gattc_read_by_uuid | ( | uint8_t | conn_idx,
|  | uint16_t | start_hdl,
|  | uint16_t | end_hdl,
|  | const ble_uuid_t * | p_char_uuid
| ) |  |

Read Attribute by UUID.

Note
  Function callback gattc_cb_fun_t::app_gattc_read_cb will be called when Read is finished.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | start_hdl | Start handle.
  [in] | end_hdl | End handle.
  [in] | p_char_uuid | Pointer to Characteristic UUID.

Return values

  SDK_SUCCESS | Successfully start the Read using Characteristic UUID procedure.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_read_multiple()

uint16_t ble_gattc_read_multiple | ( | uint8_t | conn_idx,
|  | const gattc_read_multiple_t * | p_param
| ) |  |

Initiate a Read Multiple Characteristic Values procedure.

Note
  Function callback gattc_cb_fun_t::app_gattc_read_cb will be called for each handle value which is read.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | p_param | Pointer to the parameters of the value.

Return values

  SDK_SUCCESS | Successfully start the Read Multiple Characteristic Values procedure.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_services_browse()

uint16_t ble_gattc_services_browse | ( | uint8_t | conn_idx,
|  | const ble_uuid_t * | p_srvc_uuid
| ) |  |

Browse all Primary Services or specific Primary Service information on remote GATT server.

Note
  This discovery automatically searches for Primary Services, Included Services, Characteristics and Descriptors of each service. To discover one or more services only, use ble_gattc_primary_services_discover() instead. This discovery is able to search all Primary Services or a specific one. If srvc_uuid is NULL, all services are returned.
  Function callback gattc_cb_fun_t::app_gattc_srvc_browse_cb will be called for all attributes of each service found.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | p_srvc_uuid | Pointer to Service UUID. If it is NULL, all services will be returned.

Return values

  SDK_SUCCESS | Successfully start the Browse Service(s) procedure.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_write()

uint16_t ble_gattc_write | ( | uint8_t | conn_idx,
|  | uint16_t | handle,
|  | uint16_t | offset,
|  | uint16_t | length,
|  | const uint8_t * | p_value
| ) |  |

Write (long) Characteristic (Descriptor) Value.

Note
  This uses either the "Write Characteristic Value" procedure or the "Write Characteristic Descriptor" procedure, depending on the attribute pointed by handle. If offset is non-zero or the attribute length is larger than the MTU, the "Write Long Characteristic Value" procedure or the "Write Long Characteristic Descriptor" procedure will be used respectively.
  Once completed gattc_cb_fun_t::app_gattc_write_cb will be called.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | handle | The handle of the attribute to be written.
  [in] | offset | Offset into the attribute value to be written.
  [in] | length | Length of the value data in bytes.
  [in] | p_value | Pointer to the value data.

Return values

  SDK_SUCCESS | Successfully start the Write procedure.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_write_execute()

uint16_t ble_gattc_write_execute | ( | uint8_t | conn_idx,
|  | bool | execute
| ) |  |

Execute Reliable/Long Write to remote GATT server.

Note
  When this function completes, gattc_cb_fun_t::app_gattc_write_cb will be called.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | execute | True if data shall be written; false if cancel all prepared writes.

Return values

  SDK_SUCCESS | Successfully send an Execute Write request.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_write_no_resp()

uint16_t ble_gattc_write_no_resp | ( | uint8_t | conn_idx,
|  | bool | signed_write,
|  | uint16_t | handle,
|  | uint16_t | length,
|  | const uint8_t * | p_value
| ) |  |

Write Attribute to remote GATT server (without response).

Note
  If signed_write is set to false, the "Write Without Response" procedure will be used. If signed_write is set to true, the "Signed Write Without Response" procedure will be used on a link which is not encrypted. If a link is already encrypted, "Write Without Response" procedure shall be used instead of "Signed Write Without Response".
  Once completed gattc_cb_fun_t::app_gattc_write_cb will be called.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | handle | Attribute handle.
  [in] | signed_write | True if signed write should be used, false write without response.
  [in] | length | Value length.
  [in] | p_value | Value data.

Return values

  SDK_SUCCESS | Successfully start the (Signed) Write Without Response procedure.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_gattc_write_prepare()

uint16_t ble_gattc_write_prepare | ( | uint8_t | conn_idx,
|  | uint16_t | handle,
|  | uint16_t | offset,
|  | uint16_t | length,
|  | const uint8_t * | p_value
| ) |  |

Prepare Long/Reliable Write to remote GATT server.

Note
  When this function completes, gattc_cb_fun_t::app_gattc_write_cb will be called.

Parameters

  [in] | conn_idx | Current connection index.
  [in] | handle | Attribute handle.
  [in] | offset | Value offset to start with.
  [in] | length | Value length.
  [in] | p_value | Value data.

Return values

  SDK_SUCCESS | Successfully send a Prepare Write request.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.