dotstack API Reference  1.10.37
Modules | Data Structures | Macros | Functions
GATT Client

This module describes functions and data structures used to implement a GATT client (central). More...

Modules

 Configuration
 This module describes parameters used to configure GATT client.
 

Data Structures

struct  bt_att_client_uuid_t
 UUID. More...
 
struct  bt_gatt_client_service_definition_t
 Service Definition. More...
 
struct  bt_gatt_client_inc_service_declaration_t
 Included Service Declaration. More...
 
struct  bt_gatt_client_char_declaration_t
 Characteristic Declaration. More...
 
struct  bt_gatt_client_char_value_t
 Characteristic Value. More...
 
struct  bt_gatt_client_char_descriptor_t
 Characteristic Descriptor Declaration. More...
 
struct  bt_gatt_client_evt_exchange_mtu_completed_t
 Parameter to GATT_CLIENT_EVT_EXCHANGE_MTU_COMPLETED event. More...
 
struct  bt_gatt_client_evt_discover_all_services_completed_t
 Parameter to GATT_CLIENT_EVT_DISCOVER_ALL_SERVICES_COMPLETED event. More...
 
struct  bt_gatt_client_evt_discover_service_by_uuid_completed_t
 Parameter to GATT_CLIENT_EVT_DISCOVER_SERVICE_BY_UUID_COMPLETED event. More...
 
struct  bt_gatt_client_evt_find_included_completed_t
 Parameter to GATT_CLIENT_EVT_FIND_INCLUDED_SERVICES_COMPLETED event. More...
 
struct  bt_gatt_client_evt_discover_all_chars_completed_t
 Parameter to GATT_CLIENT_EVT_DISCOVER_ALL_CHARS_COMPLETED event. More...
 
struct  bt_gatt_client_evt_discover_char_by_uuid_completed_t
 Parameter to GATT_CLIENT_EVT_DISCOVER_CHAR_BY_UUID_COMPLETED event. More...
 
struct  bt_gatt_client_evt_read_char_value_completed_t
 Parameter to GATT_CLIENT_EVT_READ_CHAR_VALUE_COMPLETED event. More...
 
struct  bt_gatt_client_evt_read_by_char_uuid_completed_t
 Parameter to GATT_CLIENT_EVT_READ_USING_CHAR_UUID_COMPLETED event. More...
 
struct  bt_gatt_client_evt_read_multiple_char_values_completed_t
 Parameter to GATT_CLIENT_EVT_READ_MULTIPLE_CHAR_VALUES_COMPLETED event. More...
 
struct  bt_gatt_client_evt_read_char_long_value_completed_t
 Parameter to GATT_CLIENT_EVT_READ_CHAR_LONG_VALUE_COMPLETED event. More...
 
struct  bt_gatt_client_evt_write_char_value_completed_t
 Parameter to GATT_CLIENT_EVT_WRITE_CHAR_VALUE_COMPLETED event. More...
 
struct  bt_gatt_client_evt_write_char_long_value_completed_t
 Parameter to GATT_CLIENT_EVT_WRITE_CHAR_LONG_VALUE_COMPLETED event. More...
 
struct  bt_gatt_client_evt_prepare_write_char_long_value_completed_t
 Parameter to GATT_CLIENT_EVT_PREPARE_WRITE_CHAR_LONG_VALUE_COMPLETED event. More...
 
struct  bt_gatt_client_evt_value_notification_t
 Parameter to GATT_CLIENT_EVT_VALUE_NOTIFICATION event. More...
 
struct  bt_gatt_client_evt_discover_descriptors_completed_t
 Parameter to GATT_CLIENT_EVT_DISCOVER_CHAR_DESCRIPTORS_COMPLETED event. More...
 
struct  bt_gatt_client_evt_read_char_descriptor_completed_t
 Parameter to GATT_CLIENT_EVT_READ_CHAR_DESCRIPTOR_COMPLETED event. More...
 
struct  bt_gatt_client_evt_read_char_long_descriptor_completed_t
 Parameter to GATT_CLIENT_EVT_READ_CHAR_LONG_DESCRIPTOR_COMPLETED event. More...
 
struct  bt_gatt_client_evt_write_char_descriptor_completed_t
 Parameter to GATT_CLIENT_EVT_WRITE_CHAR_DESCRIPTOR_COMPLETED event. More...
 
struct  bt_gatt_client_evt_write_char_long_descriptor_completed_t
 Parameter to GATT_CLIENT_EVT_WRITE_CHAR_LONG_DESCRIPTOR_COMPLETED event. More...
 
struct  bt_gatt_client_evt_conn_param_update_t
 Parameter to GATT_CLIENT_EVT_CONN_PARAM_UPDATE_REQUEST event. More...
 
struct  bt_gatt_client_evt_conn_param_update_completed_t
 Parameter to GATT_CLIENT_EVT_CONN_PARAM_UPDATE_COMPLETED event. More...
 
struct  bt_gatt_client_evt_tran_timeout_t
 Parameter to GATT_CLIENT_EVT_TRAN_TIMEOUT event. More...
 
struct  bt_gatt_client_evt_write_char_value_wo_resp_completed_t
 Parameter to GATT_CLIENT_EVT_WRITE_CHAR_VAL_WO_RESP_COMPLETED event. More...
 
struct  bt_gatt_client_evt_signed_write_char_value_wo_resp_completed_t
 Parameter to GATT_CLIENT_EVT_SIGNED_WRITE_CHAR_VAL_WO_RESP_COMPLETED event. More...
 
union  bt_gatt_client_evt_t
 Parameter to GATT client application callback. More...
 

Macros

#define bt_gatt_client_accept_conn_param_update(session, min_interval, max_interval, slave_latency, supervision_timeout, min_ce_length, max_ce_length)   bt_att_client_accept_conn_param_update(session->att_session, min_interval, max_interval, slave_latency, supervision_timeout, min_ce_length, max_ce_length)
 Accept connection parameters update. More...
 
#define bt_gatt_client_reject_conn_param_update(session)   bt_att_client_reject_conn_param_update(session->att_session)
 Reject connection parameters update. More...
 

Functions

bt_bool bt_gatt_client_init (void)
 Initialize the GATT client. More...
 
bt_gatt_client_mgr_tbt_gatt_get_client_mgr (void)
 Return a pointer to an instance of the GATT client manager. More...
 
bt_gatt_client_session_t * bt_gatt_client_allocate_session (bt_gatt_client_session_callback_fp callback, void *callback_param)
 Allocate GATT client session. More...
 
void bt_gatt_client_free_sessions (bt_gatt_client_session_t *session)
 Destroy GATT client session. More...
 
bt_bool bt_gatt_client_connect (bt_gatt_client_session_t *session, bt_bdaddr_t *addr)
 Connect to a remote device (peripheral). More...
 
bt_bool bt_gatt_client_disconnect (bt_gatt_client_session_t *session)
 Disconnect from a remote device. More...
 
bt_bool bt_gatt_exchange_mtu (bt_gatt_client_session_t *session, bt_uint mtu)
 Exchange MTU. More...
 
bt_bool bt_gatt_client_discover_all_services_ex (bt_gatt_client_session_t *session, bt_uint service_type, bt_uint start_handle, bt_gatt_client_service_definition_t *result, bt_uint max_results)
 Discover All Services. More...
 
bt_bool bt_gatt_client_discover_by_service_uuid (bt_gatt_client_session_t *session, bt_uint service_uuid, bt_gatt_client_service_definition_t *result, bt_uint max_results)
 Discover Services by UUID (16-bit). More...
 
bt_bool bt_gatt_client_find_included_services_ex (bt_gatt_client_session_t *session, const bt_gatt_client_service_definition_t *service, bt_uint start_handle, bt_gatt_client_inc_service_declaration_t *result, bt_uint max_results)
 Find Included Services. More...
 
bt_bool bt_gatt_client_discover_by_service_uuid_80 (bt_gatt_client_session_t *session, bt_uuid_t *service_uuid, bt_gatt_client_service_definition_t *result, bt_uint max_results)
 Discover Services by UUID (128-bit). More...
 
bt_bool bt_gatt_client_discover_all_chars_ex (bt_gatt_client_session_t *session, const bt_gatt_client_service_definition_t *service, bt_uint start_handle, bt_gatt_client_char_declaration_t *result, bt_uint max_results)
 Discover All Characteristics of a Service. More...
 
bt_bool bt_gatt_client_discover_char_by_uuid (bt_gatt_client_session_t *session, const bt_gatt_client_service_definition_t *service, bt_uint char_uuid, bt_gatt_client_char_declaration_t *result, bt_uint max_results)
 Discover Characteristics by UUID (16-bit). More...
 
bt_bool bt_gatt_client_discover_char_by_uuid_80 (bt_gatt_client_session_t *session, const bt_gatt_client_service_definition_t *service, bt_uuid_t *char_uuid, bt_gatt_client_char_declaration_t *result, bt_uint max_results)
 Discover Characteristics by UUID (128-bit). More...
 
bt_bool bt_gatt_client_read_char_value (bt_gatt_client_session_t *session, const bt_gatt_client_char_declaration_t *characteristic, bt_byte *buffer, bt_uint len)
 Read Characteristic Value. More...
 
bt_bool bt_gatt_client_read_by_char_uuid (bt_gatt_client_session_t *session, const bt_gatt_client_service_definition_t *service, bt_uint char_uuid, bt_gatt_client_char_value_t *result, bt_uint max_results)
 Read Using Characteristic UUID (16-bit). More...
 
bt_bool bt_gatt_client_read_by_char_uuid_80 (bt_gatt_client_session_t *session, const bt_gatt_client_service_definition_t *service, bt_uuid_t *char_uuid, bt_gatt_client_char_value_t *result, bt_uint max_results)
 Read Using Characteristic UUID (128-bit). More...
 
bt_bool bt_gatt_client_read_char_long_value (bt_gatt_client_session_t *session, const bt_gatt_client_char_declaration_t *characteristic, bt_uint offset, bt_byte *buffer, bt_uint len)
 Read Long Characteristic Value. More...
 
bt_bool bt_gatt_client_read_multiple_char_values (bt_gatt_client_session_t *session, const bt_uint *handles, bt_uint count, bt_byte *buffer, bt_uint len)
 Read Multiple Characteristic Values. More...
 
bt_bool bt_gatt_client_write_char_value (bt_gatt_client_session_t *session, const bt_gatt_client_char_declaration_t *characteristic, const bt_byte *value, bt_uint len)
 Write Characteristic Value. More...
 
bt_bool bt_gatt_client_set_char_value (bt_gatt_client_session_t *session, const bt_gatt_client_char_declaration_t *characteristic, const bt_byte *value, bt_uint len)
 Write Without Response. More...
 
bt_bool bt_gatt_client_write_char_long_value (bt_gatt_client_session_t *session, const bt_gatt_client_char_declaration_t *characteristic, bt_uint value_offset, const bt_byte *value, bt_uint len)
 Write Long Characteristic Value. More...
 
bt_bool bt_gatt_client_discover_char_descriptors (bt_gatt_client_session_t *session, const bt_gatt_client_char_declaration_t *characteristic, bt_gatt_client_char_descriptor_t *result, bt_uint max_results)
 Discover All Characteristic Descriptors. More...
 
bt_bool bt_gatt_client_read_char_descriptor (bt_gatt_client_session_t *session, const bt_gatt_client_char_descriptor_t *descriptor, bt_byte *buffer, bt_uint len)
 Read Characteristic Descriptor. More...
 
bt_bool bt_gatt_client_read_char_long_descriptor (bt_gatt_client_session_t *session, const bt_gatt_client_char_descriptor_t *descriptor, bt_uint offset, bt_byte *buffer, bt_uint len)
 Read Long Characteristic Descriptor. More...
 
bt_bool bt_gatt_client_write_char_descriptor (bt_gatt_client_session_t *session, const bt_gatt_client_char_descriptor_t *descriptor, const bt_byte *value, bt_uint len)
 Write Characteristic Descriptor. More...
 
bt_bool bt_gatt_client_write_char_long_descriptor (bt_gatt_client_session_t *session, const bt_gatt_client_char_descriptor_t *descriptor, bt_uint value_offset, const bt_byte *value, bt_uint len)
 Write Long Characteristic Descriptor. More...
 
bt_hci_conn_state_t * bt_gatt_client_get_hci_connection (const bt_gatt_client_session_t *session)
 Get HCI connection for a session. More...
 

Events

#define GATT_CLIENT_EVT_SESSION_CONNECTED   1
 This event is generated when the client connected to the server.
 
#define GATT_CLIENT_EVT_SESSION_DISCONNECTED   2
 This event is generated when the client disconnected from the server.
 
#define GATT_CLIENT_EVT_CONNECTION_FAILED   3
 This event is generated when the client failed to connect to the server.
 
#define GATT_CLIENT_EVT_TRAN_TIMEOUT   7
 This event is generated if operation (discover, read, write) timed out.
 
#define GATT_CLIENT_EVT_DISCOVER_ALL_SERVICES_COMPLETED   10
 This event is generated when the "discover all services" operation has completed.
 
#define GATT_CLIENT_EVT_DISCOVER_SERVICE_BY_UUID_COMPLETED   11
 This event is generated when the "discover service by UUID" operation has completed.
 
#define GATT_CLIENT_EVT_DISCOVER_ALL_CHARS_COMPLETED   12
 This event is generated when the "discover all characteristics" operation has completed.
 
#define GATT_CLIENT_EVT_READ_CHAR_VALUE_COMPLETED   13
 This event is generated when the "read characteristic value" operation has completed.
 
#define GATT_CLIENT_EVT_READ_CHAR_LONG_VALUE_COMPLETED   14
 This event is generated when the "read long characteristic value" operation has completed.
 
#define GATT_CLIENT_EVT_WRITE_CHAR_VALUE_COMPLETED   15
 This event is generated when the "write characteristic value" operation has completed.
 
#define GATT_CLIENT_EVT_WRITE_CHAR_LONG_VALUE_COMPLETED   16
 This event is generated when the "write long characteristic value" operation has completed.
 
#define GATT_CLIENT_EVT_VALUE_NOTIFICATION   17
 This event is generated when the client received value notification or indication.
 
#define GATT_CLIENT_EVT_DISCOVER_CHAR_DESCRIPTORS_COMPLETED   18
 This event is generated when the "discover characteristic descriptors" operation has completed.
 
#define GATT_CLIENT_EVT_WRITE_CHAR_DESCRIPTOR_COMPLETED   19
 This event is generated when the "write characteristic descriptor" operation has completed.
 
#define GATT_CLIENT_EVT_WRITE_CHAR_LONG_DESCRIPTOR_COMPLETED   20
 This event is generated when the "write characteristic long descriptor" operation has completed.
 
#define GATT_CLIENT_EVT_READ_CHAR_DESCRIPTOR_COMPLETED   21
 This event is generated when the "read characteristic descriptor" operation has completed.
 
#define GATT_CLIENT_EVT_READ_CHAR_LONG_DESCRIPTOR_COMPLETED   22
 This event is generated when the "read characteristic long descriptor" operation has completed.
 
#define GATT_CLIENT_EVT_EXCHANGE_MTU_COMPLETED   23
 This event is generated when the "exchange MTU" operation has completed.
 
#define GATT_CLIENT_EVT_FIND_INCLUDED_SERVICES_COMPLETED   24
 This event is generated when the "find included services" operation has completed.
 
#define GATT_CLIENT_EVT_DISCOVER_CHAR_BY_UUID_COMPLETED   25
 This event is generated when the "discover characteristic by UUID" operation has completed.
 
#define GATT_CLIENT_EVT_READ_USING_CHAR_UUID_COMPLETED   26
 This event is generated when the "read characteristic value using characteristic UUID" operation has completed.
 
#define GATT_CLIENT_EVT_READ_MULTIPLE_CHAR_VALUES_COMPLETED   27
 This event is generated when the "read multiple characteristic values" operation has completed.
 
#define GATT_CLIENT_EVT_CONN_PARAM_UPDATE_REQUEST   28
 This event is generated when the client received "connection parameter update" request.
 
#define GATT_CLIENT_EVT_CONN_PARAM_UPDATE_COMPLETED   29
 This event is generated after the new connection parameters have been set.
 
#define GATT_CLIENT_EVT_WRITE_CHAR_VAL_WO_RESP_COMPLETED   30
 This event is generated when a write command has been sent.
 
#define GATT_CLIENT_EVT_SIGNED_WRITE_CHAR_VAL_WO_RESP_COMPLETED   31
 This event is generated when a signed write command has been sent.
 
#define GATT_CLIENT_EVT_PREPARE_WRITE_CHAR_LONG_VALUE_COMPLETED   32
 This event is generated when the "prepare write long characteristic value" operation has completed.
 
#define GATT_CLIENT_EVT_PROFILE_FINDER_STARTED   100
 
#define GATT_CLIENT_EVT_PROFILE_FINDER_COMPLETED   101
 
#define GATT_CLIENT_EVT_PROFILE_FOUND   102
 

Detailed Description

This module describes functions and data structures used to implement a GATT client (central).

Macro Definition Documentation

#define bt_gatt_client_accept_conn_param_update (   session,
  min_interval,
  max_interval,
  slave_latency,
  supervision_timeout,
  min_ce_length,
  max_ce_length 
)    bt_att_client_accept_conn_param_update(session->att_session, min_interval, max_interval, slave_latency, supervision_timeout, min_ce_length, max_ce_length)

Accept connection parameters update.

When a server sends "connection parameters update" request a GATT_CLIENT_EVT_CONN_PARAM_UPDATE_REQUEST event is generated. Client has to either accept the request or deny it. bt_gatt_client_accept_conn_param_update is used to accept the request.

Parameters
sessionGATT session.
min_intervalMinimum connection interval expressed in 1.25ms units.
max_intervalMaximum connection interval expressed in 1.25ms units.
slave_latencySlave latency expressed as number of connection events.
supervision_timeoutLink supervision timeout expressed in 10ms units.
min_ce_lengthInformation parameter about the minimum length of connection needed for this LE connection expressed in 0.625ms units.
max_ce_lengthInformation parameter about the maximum length of connection needed for this LE connection expressed in 0.625ms units.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
#define bt_gatt_client_reject_conn_param_update (   session)    bt_att_client_reject_conn_param_update(session->att_session)

Reject connection parameters update.

When a server sends "connection parameters update" request a GATT_CLIENT_EVT_CONN_PARAM_UPDATE_REQUEST event is generated. Client has to either accept the request or deny it. bt_gatt_client_reject_conn_param_update is used to deny the request.

Parameters
sessionGATT session.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.

Function Documentation

bt_gatt_client_session_t* bt_gatt_client_allocate_session ( bt_gatt_client_session_callback_fp  callback,
void *  callback_param 
)

Allocate GATT client session.

This function allocates a new GATT client session.

Parameters
callbackThe callback function that will be called when the GATT client generates an event.
callback_paramA pointer to arbitrary data to be passed to the callback callback.
Returns
  • A pointer to the new GATT client session structure if the function succeeds.
  • NULL otherwise.
bt_bool bt_gatt_client_connect ( bt_gatt_client_session_t *  session,
bt_bdaddr_t *  addr 
)

Connect to a remote device (peripheral).

This function establishes a connection to a remote device specified by the addr. If connection cannot be initiated for some reason, for example, there is not enough resources, it returns FALSE and no events are generated. Otherwise the result of an attempt to connect to the remote device is reported via the GATT client callback. The events generated will either be GATT_CLIENT_SESSION_EVT_SESSION_CONNECTED or GATT_CLIENT_SESSION_EVT_CONNECTION_FAILED.

Parameters
sessionGATT session.
addrThe address of a remote device.
Returns
  • TRUE if connection establishment has been started.
  • FALSE otherwise.
bt_bool bt_gatt_client_disconnect ( bt_gatt_client_session_t *  session)

Disconnect from a remote device.

This function closes a connection to a remote device. After the connection has been terminated the GATT client callback is called with GATT_CLIENT_SESSION_EVT_SESSION_DISCONNECTED event.

Parameters
sessionGATT session.
Returns
  • TRUE if disconnection has been started.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_discover_all_chars_ex ( bt_gatt_client_session_t *  session,
const bt_gatt_client_service_definition_t service,
bt_uint  start_handle,
bt_gatt_client_char_declaration_t result,
bt_uint  max_results 
)

Discover All Characteristics of a Service.

This function finds all the characteristic declarations within a service definition on a server.

Parameters
sessionGATT session.
serviceService definition.
start_handleFirst attribute handle from which the server has to start searching for characteristic declarations.
resultPointer to a buffer where the client will store found characteristic declarations.
max_resultThe maximum number of characteristic declarations that can be stored in result.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_discover_all_services_ex ( bt_gatt_client_session_t *  session,
bt_uint  service_type,
bt_uint  start_handle,
bt_gatt_client_service_definition_t result,
bt_uint  max_results 
)

Discover All Services.

This function discovers all the primary services on the server.

Parameters
sessionGATT session.
start_handleFirst attribute handle from which the server has to start searching for services.
resultPointer to a buffer where the client will store definitions of the found services.
max_resultThe maximum number of service definitions that can be stored in result.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_discover_by_service_uuid ( bt_gatt_client_session_t *  session,
bt_uint  service_uuid,
bt_gatt_client_service_definition_t result,
bt_uint  max_results 
)

Discover Services by UUID (16-bit).

This function discovers a specific primary service on the server when only the Service UUID is known.

Parameters
sessionGATT session.
service_uuid16-bit Service UUID.
resultPointer to a buffer where the client will store definitions of the found services.
max_resultThe maximum number of service definitions that can be stored in result.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_discover_by_service_uuid_80 ( bt_gatt_client_session_t *  session,
bt_uuid_t *  service_uuid,
bt_gatt_client_service_definition_t result,
bt_uint  max_results 
)

Discover Services by UUID (128-bit).

This function discovers a specific primary service on the server when only the Service UUID is known.

Parameters
sessionGATT session.
service_uuid128-bit Service UUID.
resultPointer to a buffer where the client will store definitions of the found services.
max_resultThe maximum number of service definitions that can be stored in result.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_discover_char_by_uuid ( bt_gatt_client_session_t *  session,
const bt_gatt_client_service_definition_t service,
bt_uint  char_uuid,
bt_gatt_client_char_declaration_t result,
bt_uint  max_results 
)

Discover Characteristics by UUID (16-bit).

This function finds characteristic declarations within a service definition on a server by the characteristic UUID.

Parameters
sessionGATT session.
serviceService definition.
char_uuid16-bit characteristic UUID.
resultPointer to a buffer where the client will store found characteristic declarations.
max_resultThe maximum number of characteristic declarations that can be stored in result.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_discover_char_by_uuid_80 ( bt_gatt_client_session_t *  session,
const bt_gatt_client_service_definition_t service,
bt_uuid_t *  char_uuid,
bt_gatt_client_char_declaration_t result,
bt_uint  max_results 
)

Discover Characteristics by UUID (128-bit).

This function finds characteristic declarations within a service definition on a server by the characteristic UUID.

Parameters
sessionGATT session.
serviceService definition.
char_uuid128-bit characteristic UUID.
resultPointer to a buffer where the client will store found characteristic declarations.
max_resultThe maximum number of characteristic declarations that can be stored in result.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_discover_char_descriptors ( bt_gatt_client_session_t *  session,
const bt_gatt_client_char_declaration_t characteristic,
bt_gatt_client_char_descriptor_t result,
bt_uint  max_results 
)

Discover All Characteristic Descriptors.

This function finds all the characteristic descriptors.

Parameters
sessionGATT session.
characteristicCharacteristic declaration.
start_handleFirst attribute handle from which the server has to start searching for characteristic declarations.
resultPointer to a buffer where the client will store found characteristic descriptors.
max_resultThe maximum number of characteristic descriptors that can be stored in result.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_find_included_services_ex ( bt_gatt_client_session_t *  session,
const bt_gatt_client_service_definition_t service,
bt_uint  start_handle,
bt_gatt_client_inc_service_declaration_t result,
bt_uint  max_results 
)

Find Included Services.

This function finds include service declarations within a service definition on a server.

Parameters
sessionGATT session.
serviceService definition.
start_handleFirst attribute handle from which the server has to start searching for include service declarations.
resultPointer to a buffer where the client will store found include service declarations.
max_resultThe maximum number of include service declarations that can be stored in result.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
void bt_gatt_client_free_sessions ( bt_gatt_client_session_t *  session)

Destroy GATT client session.

This function frees memory used by the session. The session has to exist and be in the "idle" state for this function to succeed. I.e. the session has to be disconnected before this function can be called.

Parameters
sessionGATT session.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise.
bt_hci_conn_state_t* bt_gatt_client_get_hci_connection ( const bt_gatt_client_session_t *  session)

Get HCI connection for a session.

This function returns a pointer to a structure that describes an HCI connection a session is open on. The return value can be used to call various function from the HCI layer. For example, if an app wants to force disconnection from a remote device it can call bt_hci_disconnect.

Parameters
sessionGATT session.
Returns
  • Pointer to a structure that describes an HCI connection if the function succeeds.
  • NULL otherwise. The function fails only if a session specified by the session parameter
  • does not exist or there is no HCI connection between local and remote devices associated with the session.
bt_bool bt_gatt_client_init ( void  )

Initialize the GATT client.

This function initializes the GATT client of the stack. It must be called prior to any other GATT client function can be called.

Returns
Always TRUE
bt_bool bt_gatt_client_read_by_char_uuid ( bt_gatt_client_session_t *  session,
const bt_gatt_client_service_definition_t service,
bt_uint  char_uuid,
bt_gatt_client_char_value_t result,
bt_uint  max_results 
)

Read Using Characteristic UUID (16-bit).

This function reads characteristic values from a server when only the characteristic UUID is known.

Parameters
sessionGATT session.
serviceService definition.
char_uuid16-bit characteristic UUID.
resultPointer to a buffer where the client will store characteristic values.
max_resultThe maximum number of characteristic values that can be stored in result.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_read_by_char_uuid_80 ( bt_gatt_client_session_t *  session,
const bt_gatt_client_service_definition_t service,
bt_uuid_t *  char_uuid,
bt_gatt_client_char_value_t result,
bt_uint  max_results 
)

Read Using Characteristic UUID (128-bit).

This function reads characteristic values from a server when only the characteristic UUID is known.

Parameters
sessionGATT session.
serviceService definition.
char_uuid128-bit characteristic UUID.
resultPointer to a buffer where the client will store characteristic values.
max_resultThe maximum number of characteristic values that can be stored in result.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_read_char_descriptor ( bt_gatt_client_session_t *  session,
const bt_gatt_client_char_descriptor_t descriptor,
bt_byte *  buffer,
bt_uint  len 
)

Read Characteristic Descriptor.

This function reads characteristic descriptor.

Parameters
sessionGATT session.
descriptorCharacteristic descriptor.
bufferPointer to a buffer where the client will store the characteristic's descriptor.
lenThe length of the buffer.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_read_char_long_descriptor ( bt_gatt_client_session_t *  session,
const bt_gatt_client_char_descriptor_t descriptor,
bt_uint  offset,
bt_byte *  buffer,
bt_uint  len 
)

Read Long Characteristic Descriptor.

This function reads long characteristic descriptor.

Parameters
sessionGATT session.
descriptorCharacteristic descriptor.
offsetThe offset of the first octet to read.
bufferPointer to a buffer where the client will store the characteristic's descriptor.
lenThe length of the buffer.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_read_char_long_value ( bt_gatt_client_session_t *  session,
const bt_gatt_client_char_declaration_t characteristic,
bt_uint  offset,
bt_byte *  buffer,
bt_uint  len 
)

Read Long Characteristic Value.

This function reads characteristic value.

Parameters
sessionGATT session.
characteristicCharacteristic declaration.
offsetThe offset of the first octet to read.
bufferPointer to a buffer where the client will store the characteristic's value.
lenThe length of the buffer.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_read_char_value ( bt_gatt_client_session_t *  session,
const bt_gatt_client_char_declaration_t characteristic,
bt_byte *  buffer,
bt_uint  len 
)

Read Characteristic Value.

This function reads characteristic value.

Parameters
sessionGATT session.
characteristicCharacteristic declaration.
bufferPointer to a buffer where the client will store the characteristic's value.
lenThe length of the buffer.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_read_multiple_char_values ( bt_gatt_client_session_t *  session,
const bt_uint *  handles,
bt_uint  count,
bt_byte *  buffer,
bt_uint  len 
)

Read Multiple Characteristic Values.

This function reads multiple characteristic values from a server when the characteristic value handles are known.

Parameters
sessionGATT session.
handlesAn array of characteristic value handles.
countThe number of handles.
bufferPointer to a buffer where the client will store the characteristic values.
lenThe length of the buffer.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_set_char_value ( bt_gatt_client_session_t *  session,
const bt_gatt_client_char_declaration_t characteristic,
const bt_byte *  value,
bt_uint  len 
)

Write Without Response.

This function writes characteristic value to a server using ATT "write" command, i.e. the server will not send a response after writing the value.

Parameters
sessionGATT session.
characteristicCharacteristic declaration.
valueCharacteristic value.
lenThe length of the value.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_write_char_descriptor ( bt_gatt_client_session_t *  session,
const bt_gatt_client_char_descriptor_t descriptor,
const bt_byte *  value,
bt_uint  len 
)

Write Characteristic Descriptor.

This function writes characteristic descriptor.

Parameters
sessionGATT session.
descriptorCharacteristic descriptor.
valueCharacteristic descriptor value.
lenThe length of the value.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_write_char_long_descriptor ( bt_gatt_client_session_t *  session,
const bt_gatt_client_char_descriptor_t descriptor,
bt_uint  value_offset,
const bt_byte *  value,
bt_uint  len 
)

Write Long Characteristic Descriptor.

This function writes characteristic descriptor.

Parameters
sessionGATT session.
descriptorCharacteristic descriptor.
value_offsetThe offset of the first octet to be written.
valueCharacteristic descriptor value.
lenThe length of the buffer.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_write_char_long_value ( bt_gatt_client_session_t *  session,
const bt_gatt_client_char_declaration_t characteristic,
bt_uint  value_offset,
const bt_byte *  value,
bt_uint  len 
)

Write Long Characteristic Value.

This function writes characteristic value to a server using ATT "prepare write" and "execute write" requests.

Parameters
sessionGATT session.
characteristicCharacteristic declaration.
value_offsetThe offset of the first octet to be written.
valueCharacteristic value.
lenThe length of the value.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_client_write_char_value ( bt_gatt_client_session_t *  session,
const bt_gatt_client_char_declaration_t characteristic,
const bt_byte *  value,
bt_uint  len 
)

Write Characteristic Value.

This function writes characteristic value to a server using ATT "write" request, i.e. the server will send a response after writing the value.

Parameters
sessionGATT session.
characteristicCharacteristic declaration.
valueCharacteristic value.
lenThe length of the value.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_bool bt_gatt_exchange_mtu ( bt_gatt_client_session_t *  session,
bt_uint  mtu 
)

Exchange MTU.

This function informs the server about the client's MTU. In response to the "exchange MTU" request the server sends its MTU to the client.

Parameters
sessionGATT session.
mtuClient's MTU.
Returns
  • TRUE if a request has been sent.
  • FALSE otherwise. No events will be generated.
bt_gatt_client_mgr_t* bt_gatt_get_client_mgr ( void  )

Return a pointer to an instance of the GATT client manager.

This function returns a pointer to an instance of the GATT client manager. There is only one instance of the manager allocated by the stack.

Returns
  • A pointer to the GATT client manager.