SmartSnippets DA1459x SDK
Files | Data Structures | Typedefs | Enumerations | Functions

GATT client API. More...

Files

file  ble_client.h
 GATT Client handling routines API.
 
file  gatt_client.h
 Generic Attribute Service Client header file.
 

Data Structures

struct  ble_client
 

Typedefs

typedef struct ble_client ble_client_t
 
typedef void(* read_completed_evt_t) (ble_client_t *client, const ble_evt_gattc_read_completed_t *evt)
 Read completed callback. More...
 
typedef void(* write_completed_evt_t) (ble_client_t *client, const ble_evt_gattc_write_completed_t *evt)
 Write completed callback. More...
 
typedef void(* notification_evt_t) (ble_client_t *client, const ble_evt_gattc_notification_t *evt)
 Notification callback. More...
 
typedef void(* indication_evt_t) (ble_client_t *client, const ble_evt_gattc_indication_t *evt)
 Indication callback. More...
 
typedef void(* disconnect_evt_t) (ble_client_t *client, const ble_evt_gap_disconnected_t *evt)
 Disconnected callback. More...
 
typedef void(* serialize_cb_t) (ble_client_t *client, void *data, size_t *length)
 Serialize callback. More...
 
typedef void(* attach_cb_t) (ble_client_t *client)
 Attach callback. More...
 
typedef void(* cleanup_cb_t) (ble_client_t *client)
 Cleanup callback. More...
 

Enumerations

enum  gatt_client_event_t { GATT_CLIENT_EVENT_SERVICE_CHANGED_INDICATE = 0x01 }
 
enum  gatt_client_cap_t { GATT_CLIENT_CAP_SERVICE_CHANGED = 0x01 }
 

Functions

void ble_client_add (ble_client_t *client)
 Add client. More...
 
void ble_client_remove (const ble_client_t *client)
 Remove client. More...
 
void ble_client_cleanup (ble_client_t *client)
 Cleanup client. More...
 
void ble_clients_cleanup (void)
 Cleanup all clients. More...
 
void ble_client_serialize (ble_client_t *client, void *data, size_t *length)
 Serialize client. More...
 
void ble_client_attach (ble_client_t *client, uint16_t conn_idx)
 Attach client. More...
 
void ble_client_handle_event (const ble_evt_hdr_t *evt)
 Handle BLE event. More...
 
__STATIC_INLINE bool ble_client_in_range (const ble_client_t *client, uint16_t start_h, uint16_t end_h)
 Check if client is in given handles range. More...
 
ble_client_tgatt_client_init (const gatt_client_callbacks_t *cb, const ble_evt_gattc_browse_svc_t *evt)
 Register GATT Client instance. More...
 
ble_client_tgatt_client_init_from_data (uint16_t conn_idx, const gatt_client_callbacks_t *cb, const void *data, size_t length)
 Initialize and register GATT Client instance from data buffer. More...
 
gatt_client_cap_t gatt_client_get_capabilites (ble_client_t *gatt_client)
 Get Gatt client capabilities. More...
 
bool gatt_client_set_event_state (ble_client_t *gatt_client, gatt_client_event_t event, bool enable)
 Set event state. More...
 
bool gatt_client_get_event_state (ble_client_t *gatt_client, gatt_client_event_t event)
 Get event state. More...
 

Detailed Description

GATT client API.

Generic Attribute Service Client.

Typedef Documentation

◆ attach_cb_t

typedef void(* attach_cb_t) (ble_client_t *client)

Attach callback.

Function to be called when a client is attached to a new connection index.

Parameters
[in]clientclient instance

◆ ble_client_t

typedef struct ble_client ble_client_t

BLE Client structure

◆ cleanup_cb_t

typedef void(* cleanup_cb_t) (ble_client_t *client)

Cleanup callback.

Function to be called when a client is destroyed.

Parameters
[in]clientclient instance

◆ disconnect_evt_t

typedef void(* disconnect_evt_t) (ble_client_t *client, const ble_evt_gap_disconnected_t *evt)

Disconnected callback.

Function to be called when disconnected from a remote device.

Parameters
[in]clientclient instance
[in]evtdisconnected event

◆ indication_evt_t

typedef void(* indication_evt_t) (ble_client_t *client, const ble_evt_gattc_indication_t *evt)

Indication callback.

Function to be called when an indication has been received.

Parameters
[in]clientclient instance
[in]evtindication event

◆ notification_evt_t

typedef void(* notification_evt_t) (ble_client_t *client, const ble_evt_gattc_notification_t *evt)

Notification callback.

Function to be called when a notification has been received.

Parameters
[in]clientclient instance
[in]evtnotification event

◆ read_completed_evt_t

typedef void(* read_completed_evt_t) (ble_client_t *client, const ble_evt_gattc_read_completed_t *evt)

Read completed callback.

Function to be called when a read request has been completed.

Parameters
[in]clientclient instance
[in]evtread completed event

◆ serialize_cb_t

typedef void(* serialize_cb_t) (ble_client_t *client, void *data, size_t *length)

Serialize callback.

Function to be called when serialization occurs - pack client's data to the specified buffer. data must be a buffer with proper length in this case.

If called with NULL as data, then length will be set to required buffer size. Serialization will not be triggered in this case.

Note
If client cannot be serialized then length is set to 0. Otherwise length is set to the number of bytes used the serialized client.
Parameters
[in]clientclient instance
[out]datadata buffer
[out]lengthused/needed buffer size
See also
ble_client_serialize

◆ write_completed_evt_t

typedef void(* write_completed_evt_t) (ble_client_t *client, const ble_evt_gattc_write_completed_t *evt)

Write completed callback.

Function to be called when a write request has been completed.

Parameters
[in]clientclient instance
[in]evtwrite completed event

Enumeration Type Documentation

◆ gatt_client_cap_t

Gatt Client capabilities

Enumerator
GATT_CLIENT_CAP_SERVICE_CHANGED 

Service Changed characteristics

◆ gatt_client_event_t

Characteristics containing CCC descriptors - may be configured for notifications or indications

Enumerator
GATT_CLIENT_EVENT_SERVICE_CHANGED_INDICATE 

Service Changed indications

Function Documentation

◆ ble_client_add()

void ble_client_add ( ble_client_t client)

Add client.

Adds a client to the internal database. It is required in order to receive client callbacks.

Parameters
[in]clientclient instance

◆ ble_client_attach()

void ble_client_attach ( ble_client_t client,
uint16_t  conn_idx 
)

Attach client.

Attaches a client to a given connection index and adds it to the internal database.

Parameters
[in]clientclient instance
[in]conn_idxnew connection index

◆ ble_client_cleanup()

void ble_client_cleanup ( ble_client_t client)

Cleanup client.

Frees the resources allocated for the client.

Parameters
[in]clientclient instance

◆ ble_client_handle_event()

void ble_client_handle_event ( const ble_evt_hdr_t evt)

Handle BLE event.

Handles BLE events and passes them to clients.

Parameters
[in]evtBLE event

◆ ble_client_in_range()

__STATIC_INLINE bool ble_client_in_range ( const ble_client_t client,
uint16_t  start_h,
uint16_t  end_h 
)

Check if client is in given handles range.

Checks if given client's handles are within given range

Parameters
[in]clientclient instance
[in]start_hstart of handle range
[in]end_hend of handle range
Returns
true if client in range, false otherwise

◆ ble_client_remove()

void ble_client_remove ( const ble_client_t client)

Remove client.

Removes a client from the internal database.

Parameters
[in]clientclient instance

◆ ble_client_serialize()

void ble_client_serialize ( ble_client_t client,
void *  data,
size_t *  length 
)

Serialize client.

Pack client's data to the buffer from which client could be initialized in the future. data must be a buffer with proper length in this case.

If called with NULL as data, then length will be set to required buffer size. Serialization will not be triggered in this case.

Note
If client cannot be serialized then length is set to 0. Otherwise length is set to a number of bytes used by serialized client.
Parameters
[in]clientclient instance
[out]datadata buffer
[out]lengthused/needed buffer size

◆ ble_clients_cleanup()

void ble_clients_cleanup ( void  )

Cleanup all clients.

Frees the resources allocated for all added clients.

◆ gatt_client_get_capabilites()

gatt_client_cap_t gatt_client_get_capabilites ( ble_client_t gatt_client)

Get Gatt client capabilities.

Function returns bit mask with Gatt client capabilities

Parameters
[in]gatt_clientclient instance
Returns
bit mask with Gatt client capabilities

◆ gatt_client_get_event_state()

bool gatt_client_get_event_state ( ble_client_t gatt_client,
gatt_client_event_t  event 
)

Get event state.

Functions reads CCC descriptor of Service Changed characteristic.

Parameters
[in]gatt_clientclient instance
[in]eventevent type
Returns
true if read request to CCC descriptor has been sent successfully, false otherwise.

◆ gatt_client_init()

ble_client_t* gatt_client_init ( const gatt_client_callbacks_t *  cb,
const ble_evt_gattc_browse_svc_t evt 
)

Register GATT Client instance.

Function registers GATT Client

Parameters
[in]cbapplication callbacks
[in]evtbrowse svc event with Generic Attribute Service details
Returns
client instance

◆ gatt_client_init_from_data()

ble_client_t* gatt_client_init_from_data ( uint16_t  conn_idx,
const gatt_client_callbacks_t *  cb,
const void *  data,
size_t  length 
)

Initialize and register GATT Client instance from data buffer.

Function initializes GATT Client from data buffer.

Parameters
[in]conn_idxconnection index
[in]cbapplication callbacks
[in]datadata buffer
[in]lengthdata buffer's length
Returns
client instance when initialized properly, NULL otherwise

◆ gatt_client_set_event_state()

bool gatt_client_set_event_state ( ble_client_t gatt_client,
gatt_client_event_t  event,
bool  enable 
)

Set event state.

Function enable/disable indications/notifications for given characteristic

Parameters
[in]gatt_clientclient instance
[in]eventevent type
[in]enableenable/disable flag
Returns
true if write request to CCC descriptor has been sent successfully, false otherwise.