Microchip® Advanced Software Framework

gatt_client.h File Reference
#include "hci.h"

Data Structures

struct  gatt_client
 
struct  gatt_client_characteristic_descriptor_t
 
struct  gatt_client_characteristic_t
 
struct  gatt_client_notification
 
struct  gatt_client_service_t
 

Typedefs

typedef struct
gatt_client_notification 
gatt_client_notification_t
 
typedef struct gatt_client gatt_client_t
 

Enumerations

enum  gatt_client_mtu_t {
  SEND_MTU_EXCHANGE,
  SENT_MTU_EXCHANGE,
  MTU_EXCHANGED
}
 
enum  gatt_client_state_t {
  P_READY,
  P_W2_SEND_SERVICE_QUERY,
  P_W4_SERVICE_QUERY_RESULT,
  P_W2_SEND_SERVICE_WITH_UUID_QUERY,
  P_W4_SERVICE_WITH_UUID_RESULT,
  P_W2_SEND_ALL_CHARACTERISTICS_OF_SERVICE_QUERY,
  P_W4_ALL_CHARACTERISTICS_OF_SERVICE_QUERY_RESULT,
  P_W2_SEND_CHARACTERISTIC_WITH_UUID_QUERY,
  P_W4_CHARACTERISTIC_WITH_UUID_QUERY_RESULT,
  P_W2_SEND_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY,
  P_W4_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT,
  P_W2_SEND_INCLUDED_SERVICE_QUERY,
  P_W4_INCLUDED_SERVICE_QUERY_RESULT,
  P_W2_SEND_INCLUDED_SERVICE_WITH_UUID_QUERY,
  P_W4_INCLUDED_SERVICE_UUID_WITH_QUERY_RESULT,
  P_W2_SEND_READ_CHARACTERISTIC_VALUE_QUERY,
  P_W4_READ_CHARACTERISTIC_VALUE_RESULT,
  P_W2_SEND_READ_BLOB_QUERY,
  P_W4_READ_BLOB_RESULT,
  P_W2_SEND_READ_BY_TYPE_REQUEST,
  P_W4_READ_BY_TYPE_RESPONSE,
  P_W2_SEND_READ_MULTIPLE_REQUEST,
  P_W4_READ_MULTIPLE_RESPONSE,
  P_W2_SEND_WRITE_CHARACTERISTIC_VALUE,
  P_W4_WRITE_CHARACTERISTIC_VALUE_RESULT,
  P_W2_PREPARE_WRITE,
  P_W4_PREPARE_WRITE_RESULT,
  P_W2_PREPARE_RELIABLE_WRITE,
  P_W4_PREPARE_RELIABLE_WRITE_RESULT,
  P_W2_EXECUTE_PREPARED_WRITE,
  P_W4_EXECUTE_PREPARED_WRITE_RESULT,
  P_W2_CANCEL_PREPARED_WRITE,
  P_W4_CANCEL_PREPARED_WRITE_RESULT,
  P_W2_CANCEL_PREPARED_WRITE_DATA_MISMATCH,
  P_W4_CANCEL_PREPARED_WRITE_DATA_MISMATCH_RESULT,
  P_W2_SEND_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY,
  P_W4_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT,
  P_W2_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION,
  P_W4_CLIENT_CHARACTERISTIC_CONFIGURATION_RESULT,
  P_W2_SEND_READ_CHARACTERISTIC_DESCRIPTOR_QUERY,
  P_W4_READ_CHARACTERISTIC_DESCRIPTOR_RESULT,
  P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY,
  P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT,
  P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR,
  P_W4_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
  P_W2_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR,
  P_W4_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
  P_W2_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR,
  P_W4_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
  P_W2_PREPARE_WRITE_SINGLE,
  P_W4_PREPARE_WRITE_SINGLE_RESULT,
  P_W4_CMAC_READY,
  P_W4_CMAC_RESULT,
  P_W2_SEND_SIGNED_WRITE,
  P_W4_SEND_SINGED_WRITE_DONE
}
 

Functions

uint8_t gatt_client_cancel_write (btstack_packet_handler_t callback, hci_con_handle_t con_handle)
 -> gatt complete event More...
 
void gatt_client_deserialize_characteristic (const uint8_t *packet, int offset, gatt_client_characteristic_t *characteristic)
 
void gatt_client_deserialize_characteristic_descriptor (const uint8_t *packet, int offset, gatt_client_characteristic_descriptor_t *descriptor)
 
void gatt_client_deserialize_service (const uint8_t *packet, int offset, gatt_client_service_t *service)
 
uint8_t gatt_client_discover_characteristic_descriptors (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t *characteristic)
 Discovers attribute handle and UUID of a characteristic descriptor within the specified characteristic. More...
 
uint8_t gatt_client_discover_characteristics_for_handle_range_by_uuid128 (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, uint8_t *uuid)
 
uint8_t gatt_client_discover_characteristics_for_handle_range_by_uuid16 (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, uint16_t uuid16)
 The following four functions are used to discover all characteristics within the specified service or handle range, and return those that match the given UUID. More...
 
uint8_t gatt_client_discover_characteristics_for_service (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t *service)
 Discovers all characteristics within the specified service. More...
 
uint8_t gatt_client_discover_characteristics_for_service_by_uuid128 (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t *service, uint8_t *uuid128)
 
uint8_t gatt_client_discover_characteristics_for_service_by_uuid16 (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t *service, uint16_t uuid16)
 
uint8_t gatt_client_discover_primary_services (btstack_packet_handler_t callback, hci_con_handle_t con_handle)
 Discovers all primary services. More...
 
uint8_t gatt_client_discover_primary_services_by_uuid128 (btstack_packet_handler_t callback, hci_con_handle_t con_handle, const uint8_t *uuid)
 
uint8_t gatt_client_discover_primary_services_by_uuid16 (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16)
 Discovers a specific primary service given its UUID. More...
 
uint8_t gatt_client_execute_write (btstack_packet_handler_t callback, hci_con_handle_t con_handle)
 -> gatt complete event More...
 
uint8_t gatt_client_find_included_services_for_service (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t *service)
 Finds included services within the specified service. More...
 
uint8_t gatt_client_get_mtu (hci_con_handle_t con_handle, uint16_t *mtu)
 MTU is available after the first query has completed. More...
 
void gatt_client_init (void)
 Set up GATT client. More...
 
int gatt_client_is_ready (hci_con_handle_t con_handle)
 Returns if the GATT client is ready to receive a query. More...
 
void gatt_client_listen_for_characteristic_value_updates (gatt_client_notification_t *notification, btstack_packet_handler_t packet_handler, hci_con_handle_t con_handle, gatt_client_characteristic_t *characteristic)
 Register for notifications and indications of a characteristic enabled by gatt_client_write_client_characteristic_configuration. More...
 
uint8_t gatt_client_prepare_write (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t offset, uint16_t length, uint8_t *data)
 -> gatt complete event More...
 
void gatt_client_pts_suppress_mtu_exchange (void)
 
uint8_t gatt_client_read_characteristic_descriptor (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_descriptor_t *descriptor)
 Reads the characteristic descriptor using its handle. More...
 
uint8_t gatt_client_read_characteristic_descriptor_using_descriptor_handle (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle)
 
uint8_t gatt_client_read_long_characteristic_descriptor (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_descriptor_t *descriptor)
 Reads the long characteristic descriptor using its handle. More...
 
uint8_t gatt_client_read_long_characteristic_descriptor_using_descriptor_handle (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle)
 
uint8_t gatt_client_read_long_characteristic_descriptor_using_descriptor_handle_with_offset (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle, uint16_t offset)
 
uint8_t gatt_client_read_long_value_of_characteristic (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t *characteristic)
 Reads the long characteristic value using the characteristic's value handle. More...
 
uint8_t gatt_client_read_long_value_of_characteristic_using_value_handle (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle)
 
uint8_t gatt_client_read_long_value_of_characteristic_using_value_handle_with_offset (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle, uint16_t offset)
 
uint8_t gatt_client_read_multiple_characteristic_values (btstack_packet_handler_t callback, hci_con_handle_t con_handle, int num_value_handles, uint16_t *value_handles)
 
uint8_t gatt_client_read_value_of_characteristic (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t *characteristic)
 Reads the characteristic value using the characteristic's value handle. More...
 
uint8_t gatt_client_read_value_of_characteristic_using_value_handle (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle)
 
uint8_t gatt_client_read_value_of_characteristics_by_uuid128 (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, uint8_t *uuid128)
 
uint8_t gatt_client_read_value_of_characteristics_by_uuid16 (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, uint16_t uuid16)
 Reads the characteric value of all characteristics with the uuid. More...
 
uint8_t gatt_client_reliable_write_long_value_of_characteristic (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t *data)
 Writes of the long characteristic value using the characteristic's value handle. More...
 
uint8_t gatt_client_signed_write_without_response (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t handle, uint16_t message_len, uint8_t *message)
 Writes the authenticated characteristic value using the characteristic's value handle without an acknowledgment that the write was successfully performed. More...
 
void gatt_client_stop_listening_for_characteristic_value_updates (gatt_client_notification_t *notification)
 Stop listening to characteristic value updates registered with gatt_client_listen_for_characteristic_value_updates. More...
 
uint8_t gatt_client_write_characteristic_descriptor (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_descriptor_t *descriptor, uint16_t length, uint8_t *data)
 Writes the characteristic descriptor using its handle. More...
 
uint8_t gatt_client_write_characteristic_descriptor_using_descriptor_handle (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle, uint16_t length, uint8_t *data)
 
uint8_t gatt_client_write_client_characteristic_configuration (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t *characteristic, uint16_t configuration)
 Writes the client characteristic configuration of the specified characteristic. More...
 
uint8_t gatt_client_write_long_characteristic_descriptor (btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_descriptor_t *descriptor, uint16_t length, uint8_t *data)
 
uint8_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle, uint16_t length, uint8_t *data)
 
uint8_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle_with_offset (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle, uint16_t offset, uint16_t length, uint8_t *data)
 
uint8_t gatt_client_write_long_value_of_characteristic (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t *data)
 
uint8_t gatt_client_write_long_value_of_characteristic_with_offset (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle, uint16_t offset, uint16_t length, uint8_t *data)
 
uint8_t gatt_client_write_value_of_characteristic (btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t *data)
 Writes the characteristic value using the characteristic's value handle. More...
 
uint8_t gatt_client_write_value_of_characteristic_without_response (hci_con_handle_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t *data)
 Writes the characteristic value using the characteristic's value handle without an acknowledgment that the write was successfully performed. More...
 

typedef struct gatt_client gatt_client_t

Enumerator
SEND_MTU_EXCHANGE 
SENT_MTU_EXCHANGE 
MTU_EXCHANGED 
Enumerator
P_READY 
P_W2_SEND_SERVICE_QUERY 
P_W4_SERVICE_QUERY_RESULT 
P_W2_SEND_SERVICE_WITH_UUID_QUERY 
P_W4_SERVICE_WITH_UUID_RESULT 
P_W2_SEND_ALL_CHARACTERISTICS_OF_SERVICE_QUERY 
P_W4_ALL_CHARACTERISTICS_OF_SERVICE_QUERY_RESULT 
P_W2_SEND_CHARACTERISTIC_WITH_UUID_QUERY 
P_W4_CHARACTERISTIC_WITH_UUID_QUERY_RESULT 
P_W2_SEND_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY 
P_W4_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT 
P_W2_SEND_INCLUDED_SERVICE_QUERY 
P_W4_INCLUDED_SERVICE_QUERY_RESULT 
P_W2_SEND_INCLUDED_SERVICE_WITH_UUID_QUERY 
P_W4_INCLUDED_SERVICE_UUID_WITH_QUERY_RESULT 
P_W2_SEND_READ_CHARACTERISTIC_VALUE_QUERY 
P_W4_READ_CHARACTERISTIC_VALUE_RESULT 
P_W2_SEND_READ_BLOB_QUERY 
P_W4_READ_BLOB_RESULT 
P_W2_SEND_READ_BY_TYPE_REQUEST 
P_W4_READ_BY_TYPE_RESPONSE 
P_W2_SEND_READ_MULTIPLE_REQUEST 
P_W4_READ_MULTIPLE_RESPONSE 
P_W2_SEND_WRITE_CHARACTERISTIC_VALUE 
P_W4_WRITE_CHARACTERISTIC_VALUE_RESULT 
P_W2_PREPARE_WRITE 
P_W4_PREPARE_WRITE_RESULT 
P_W2_PREPARE_RELIABLE_WRITE 
P_W4_PREPARE_RELIABLE_WRITE_RESULT 
P_W2_EXECUTE_PREPARED_WRITE 
P_W4_EXECUTE_PREPARED_WRITE_RESULT 
P_W2_CANCEL_PREPARED_WRITE 
P_W4_CANCEL_PREPARED_WRITE_RESULT 
P_W2_CANCEL_PREPARED_WRITE_DATA_MISMATCH 
P_W4_CANCEL_PREPARED_WRITE_DATA_MISMATCH_RESULT 
P_W2_SEND_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY 
P_W4_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT 
P_W2_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION 
P_W4_CLIENT_CHARACTERISTIC_CONFIGURATION_RESULT 
P_W2_SEND_READ_CHARACTERISTIC_DESCRIPTOR_QUERY 
P_W4_READ_CHARACTERISTIC_DESCRIPTOR_RESULT 
P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY 
P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT 
P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR 
P_W4_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT 
P_W2_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR 
P_W4_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT 
P_W2_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR 
P_W4_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT 
P_W2_PREPARE_WRITE_SINGLE 
P_W4_PREPARE_WRITE_SINGLE_RESULT 
P_W4_CMAC_READY 
P_W4_CMAC_RESULT 
P_W2_SEND_SIGNED_WRITE 
P_W4_SEND_SINGED_WRITE_DONE 

void gatt_client_deserialize_characteristic_descriptor ( const uint8_t *  packet,
int  offset,
gatt_client_characteristic_descriptor_t descriptor 
)
uint8_t gatt_client_discover_characteristic_descriptors ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_characteristic_t characteristic 
)

Discovers attribute handle and UUID of a characteristic descriptor within the specified characteristic.

For each found descriptor, an le_characteristic_descriptor_event_t with type set to GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.

References BTSTACK_MEMORY_ALLOC_FAILED, callback, gatt_client::callback, emit_gatt_complete_event(), gatt_client::end_group_handle, gatt_client_characteristic_t::end_handle, GATT_CLIENT_IN_WRONG_STATE, gatt_client_run(), gatt_client::gatt_client_state, is_ready(), P_W2_SEND_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY, provide_context_for_conn_handle_and_start_timer(), gatt_client::start_group_handle, and gatt_client_characteristic_t::value_handle.

uint8_t gatt_client_discover_characteristics_for_handle_range_by_uuid16 ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
uint16_t  start_handle,
uint16_t  end_handle,
uint16_t  uuid16 
)

The following four functions are used to discover all characteristics within the specified service or handle range, and return those that match the given UUID.

For each found characteristic, an le_characteristic_event_t with type set to GATT_EVENT_CHARACTERISTIC_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.

References BTSTACK_MEMORY_ALLOC_FAILED, callback, gatt_client::callback, gatt_client::characteristic_start_handle, gatt_client::end_group_handle, gatt_client::filter_with_uuid, GATT_CLIENT_IN_WRONG_STATE, gatt_client_run(), gatt_client::gatt_client_state, is_ready(), P_W2_SEND_CHARACTERISTIC_WITH_UUID_QUERY, provide_context_for_conn_handle_and_start_timer(), gatt_client::start_group_handle, gatt_client::uuid128, gatt_client::uuid16, and uuid_add_bluetooth_prefix().

Referenced by gatt_client_discover_characteristics_for_service_by_uuid16().

uint8_t gatt_client_discover_characteristics_for_service ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_service_t service 
)

Discovers all characteristics within the specified service.

For each found characteristic, an le_characteristics_event_t with type set to GATT_EVENT_CHARACTERISTIC_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.

References BTSTACK_MEMORY_ALLOC_FAILED, callback, gatt_client::callback, gatt_client::characteristic_start_handle, gatt_client::end_group_handle, gatt_client_service_t::end_group_handle, gatt_client::filter_with_uuid, GATT_CLIENT_IN_WRONG_STATE, gatt_client_run(), gatt_client::gatt_client_state, is_ready(), P_W2_SEND_ALL_CHARACTERISTICS_OF_SERVICE_QUERY, provide_context_for_conn_handle_and_start_timer(), gatt_client::start_group_handle, and gatt_client_service_t::start_group_handle.

Referenced by handle_hci_event().

uint8_t gatt_client_discover_characteristics_for_service_by_uuid128 ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_service_t service,
uint8_t *  uuid128 
)
uint8_t gatt_client_discover_characteristics_for_service_by_uuid16 ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_service_t service,
uint16_t  uuid16 
)
uint8_t gatt_client_discover_primary_services ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle 
)

Discovers all primary services.

For each found service, an le_service_event_t with type set to GATT_EVENT_SERVICE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t, with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.

References BTSTACK_MEMORY_ALLOC_FAILED, callback, gatt_client::callback, gatt_client::end_group_handle, GATT_CLIENT_IN_WRONG_STATE, gatt_client_run(), gatt_client::gatt_client_state, is_ready(), P_W2_SEND_SERVICE_QUERY, provide_context_for_conn_handle_and_start_timer(), gatt_client::start_group_handle, and gatt_client::uuid16.

uint8_t gatt_client_discover_primary_services_by_uuid16 ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
uint16_t  uuid16 
)

Discovers a specific primary service given its UUID.

This service may exist multiple times. For each found service, an le_service_event_t with type set to GATT_EVENT_SERVICE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t, with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.

References BTSTACK_MEMORY_ALLOC_FAILED, callback, gatt_client::callback, gatt_client::end_group_handle, GATT_CLIENT_IN_WRONG_STATE, gatt_client_run(), gatt_client::gatt_client_state, is_ready(), P_W2_SEND_SERVICE_WITH_UUID_QUERY, provide_context_for_conn_handle_and_start_timer(), gatt_client::start_group_handle, gatt_client::uuid128, gatt_client::uuid16, and uuid_add_bluetooth_prefix().

uint8_t gatt_client_find_included_services_for_service ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_service_t service 
)

Finds included services within the specified service.

For each found included service, an le_service_event_t with type set to GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery. Information about included service type (primary/secondary) can be retrieved either by sending an ATT find information request for the returned start group handle (returning the handle and the UUID for primary or secondary service) or by comparing the service to the list of all primary services.

References BTSTACK_MEMORY_ALLOC_FAILED, callback, gatt_client::callback, gatt_client::end_group_handle, gatt_client_service_t::end_group_handle, GATT_CLIENT_IN_WRONG_STATE, gatt_client_run(), gatt_client::gatt_client_state, is_ready(), P_W2_SEND_INCLUDED_SERVICE_QUERY, provide_context_for_conn_handle_and_start_timer(), gatt_client::start_group_handle, and gatt_client_service_t::start_group_handle.

uint8_t gatt_client_get_mtu ( hci_con_handle_t  con_handle,
uint16_t *  mtu 
)

MTU is available after the first query has completed.

If status is equal to 0, it returns the real value, otherwise the default value of 23.

References ATT_DEFAULT_MTU, GATT_CLIENT_IN_WRONG_STATE, gatt_client::mtu, MTU_EXCHANGED, gatt_client::mtu_state, and provide_context_for_conn_handle().

int gatt_client_is_ready ( hci_con_handle_t  con_handle)

Returns if the GATT client is ready to receive a query.

It is used with daemon.

References is_ready(), and provide_context_for_conn_handle().

void gatt_client_listen_for_characteristic_value_updates ( gatt_client_notification_t notification,
btstack_packet_handler_t  packet_handler,
hci_con_handle_t  con_handle,
gatt_client_characteristic_t characteristic 
)

Register for notifications and indications of a characteristic enabled by gatt_client_write_client_characteristic_configuration.

Parameters
notificationstruct used to store registration
packet_handler
con_handle
characteristic

References gatt_client_notification::attribute_handle, btstack_linked_list_add(), gatt_client_notification::callback, con_handle, gatt_client_notification::con_handle, packet_handler, and gatt_client_characteristic_t::value_handle.

Referenced by handle_hci_event().

void gatt_client_pts_suppress_mtu_exchange ( void  )
uint8_t gatt_client_read_characteristic_descriptor ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_characteristic_descriptor_t descriptor 
)

Reads the characteristic descriptor using its handle.

If the characteristic descriptor is found, an le_characteristic_descriptor_event_t with type set to GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.

References gatt_client_read_characteristic_descriptor_using_descriptor_handle(), and gatt_client_characteristic_descriptor_t::handle.

uint8_t gatt_client_read_long_characteristic_descriptor ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_characteristic_descriptor_t descriptor 
)

Reads the long characteristic descriptor using its handle.

It will be returned in several blobs. For each blob, an le_characteristic_descriptor_event_t with type set to GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.

References gatt_client_read_long_characteristic_descriptor_using_descriptor_handle(), and gatt_client_characteristic_descriptor_t::handle.

uint8_t gatt_client_read_long_characteristic_descriptor_using_descriptor_handle ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
uint16_t  descriptor_handle 
)
uint8_t gatt_client_read_long_value_of_characteristic ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_characteristic_t characteristic 
)

Reads the long characteristic value using the characteristic's value handle.

The value will be returned in several blobs. For each blob, an le_characteristic_value_event_t with type set to GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT and updated value offset will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, mark the end of read.

References gatt_client_read_long_value_of_characteristic_using_value_handle(), and gatt_client_characteristic_t::value_handle.

uint8_t gatt_client_read_long_value_of_characteristic_using_value_handle ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
uint16_t  characteristic_value_handle 
)
uint8_t gatt_client_read_value_of_characteristic ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_characteristic_t characteristic 
)

Reads the characteristic value using the characteristic's value handle.

If the characteristic value is found, an le_characteristic_value_event_t with type set to GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.

References gatt_client_read_value_of_characteristic_using_value_handle(), and gatt_client_characteristic_t::value_handle.

uint8_t gatt_client_read_value_of_characteristics_by_uuid16 ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
uint16_t  start_handle,
uint16_t  end_handle,
uint16_t  uuid16 
)

Reads the characteric value of all characteristics with the uuid.

For each found, an le_characteristic_value_event_t with type set to GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.

References BTSTACK_MEMORY_ALLOC_FAILED, callback, gatt_client::callback, gatt_client::end_group_handle, GATT_CLIENT_IN_WRONG_STATE, gatt_client_run(), gatt_client::gatt_client_state, is_ready(), P_W2_SEND_READ_BY_TYPE_REQUEST, provide_context_for_conn_handle_and_start_timer(), gatt_client::query_end_handle, gatt_client::query_start_handle, gatt_client::start_group_handle, gatt_client::uuid128, gatt_client::uuid16, and uuid_add_bluetooth_prefix().

uint8_t gatt_client_reliable_write_long_value_of_characteristic ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
uint16_t  characteristic_value_handle,
uint16_t  length,
uint8_t *  data 
)

Writes of the long characteristic value using the characteristic's value handle.

It uses server response to validate that the write was correctly received. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE marks the end of write. The write is successfully performed, if the event's status field is set to 0.

References gatt_client::attribute_handle, gatt_client::attribute_length, gatt_client::attribute_offset, gatt_client::attribute_value, BTSTACK_MEMORY_ALLOC_FAILED, callback, gatt_client::callback, GATT_CLIENT_IN_WRONG_STATE, gatt_client_run(), gatt_client::gatt_client_state, is_ready(), P_W2_PREPARE_RELIABLE_WRITE, and provide_context_for_conn_handle_and_start_timer().

uint8_t gatt_client_signed_write_without_response ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
uint16_t  handle,
uint16_t  message_len,
uint8_t *  message 
)

Writes the authenticated characteristic value using the characteristic's value handle without an acknowledgment that the write was successfully performed.

void gatt_client_stop_listening_for_characteristic_value_updates ( gatt_client_notification_t notification)

Stop listening to characteristic value updates registered with gatt_client_listen_for_characteristic_value_updates.

Parameters
notificationstruct used in gatt_client_listen_for_characteristic_value_updates

References btstack_linked_list_remove().

uint8_t gatt_client_write_characteristic_descriptor ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_characteristic_descriptor_t descriptor,
uint16_t  length,
uint8_t *  data 
)

Writes the characteristic descriptor using its handle.

The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of write. The write is successfully performed, if the event's status field is set to 0.

References gatt_client_write_characteristic_descriptor_using_descriptor_handle(), and gatt_client_characteristic_descriptor_t::handle.

uint8_t gatt_client_write_client_characteristic_configuration ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_characteristic_t characteristic,
uint16_t  configuration 
)
uint8_t gatt_client_write_long_characteristic_descriptor ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
gatt_client_characteristic_descriptor_t descriptor,
uint16_t  length,
uint8_t *  data 
)
uint8_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
uint16_t  descriptor_handle,
uint16_t  length,
uint8_t *  data 
)
uint8_t gatt_client_write_long_value_of_characteristic ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
uint16_t  characteristic_value_handle,
uint16_t  length,
uint8_t *  data 
)
uint8_t gatt_client_write_value_of_characteristic ( btstack_packet_handler_t  callback,
hci_con_handle_t  con_handle,
uint16_t  characteristic_value_handle,
uint16_t  length,
uint8_t *  data 
)

Writes the characteristic value using the characteristic's value handle.

The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of write. The write is successfully performed, if the event's status field is set to 0.

References gatt_client::attribute_handle, gatt_client::attribute_length, gatt_client::attribute_value, BTSTACK_MEMORY_ALLOC_FAILED, callback, gatt_client::callback, GATT_CLIENT_IN_WRONG_STATE, gatt_client_run(), gatt_client::gatt_client_state, is_ready(), P_W2_SEND_WRITE_CHARACTERISTIC_VALUE, and provide_context_for_conn_handle_and_start_timer().

Referenced by handle_hci_event().

uint8_t gatt_client_write_value_of_characteristic_without_response ( hci_con_handle_t  con_handle,
uint16_t  characteristic_value_handle,
uint16_t  length,
uint8_t *  data 
)

Writes the characteristic value using the characteristic's value handle without an acknowledgment that the write was successfully performed.

References att_dispatch_client_can_send_now(), ATT_WRITE_COMMAND, att_write_request(), BTSTACK_MEMORY_ALLOC_FAILED, gatt_client::con_handle, GATT_CLIENT_BUSY, GATT_CLIENT_IN_WRONG_STATE, GATT_CLIENT_VALUE_TOO_LONG, is_ready(), peripheral_mtu(), and provide_context_for_conn_handle().