GATT client API.
More...
|
| 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_t * | gatt_client_init (const gatt_client_callbacks_t *cb, const ble_evt_gattc_browse_svc_t *evt) |
| | Register GATT Client instance. More...
|
| |
| 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. 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...
|
| |
GATT client API.
Generic Attribute Service Client.
◆ attach_cb_t
Attach callback.
Function to be called when a client is attached to a new connection index.
- Parameters
-
| [in] | client | client instance |
◆ ble_client_t
◆ cleanup_cb_t
Cleanup callback.
Function to be called when a client is destroyed.
- Parameters
-
| [in] | client | client instance |
◆ disconnect_evt_t
Disconnected callback.
Function to be called when disconnected from a remote device.
- Parameters
-
| [in] | client | client instance |
| [in] | evt | disconnected event |
◆ indication_evt_t
Indication callback.
Function to be called when an indication has been received.
- Parameters
-
| [in] | client | client instance |
| [in] | evt | indication event |
◆ notification_evt_t
Notification callback.
Function to be called when a notification has been received.
- Parameters
-
| [in] | client | client instance |
| [in] | evt | notification event |
◆ read_completed_evt_t
Read completed callback.
Function to be called when a read request has been completed.
- Parameters
-
| [in] | client | client instance |
| [in] | evt | read 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] | client | client instance |
| [out] | data | data buffer |
| [out] | length | used/needed buffer size |
- See also
- ble_client_serialize
◆ write_completed_evt_t
Write completed callback.
Function to be called when a write request has been completed.
- Parameters
-
| [in] | client | client instance |
| [in] | evt | write completed event |
◆ 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
|
◆ ble_client_add()
Add client.
Adds a client to the internal database. It is required in order to receive client callbacks.
- Parameters
-
| [in] | client | client 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] | client | client instance |
| [in] | conn_idx | new connection index |
◆ ble_client_cleanup()
Cleanup client.
Frees the resources allocated for the client.
- Parameters
-
| [in] | client | client instance |
◆ ble_client_handle_event()
Handle BLE event.
Handles BLE events and passes them to clients.
- Parameters
-
◆ 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] | client | client instance |
| [in] | start_h | start of handle range |
| [in] | end_h | end of handle range |
- Returns
- true if client in range, false otherwise
◆ ble_client_remove()
Remove client.
Removes a client from the internal database.
- Parameters
-
| [in] | client | client 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] | client | client instance |
| [out] | data | data buffer |
| [out] | length | used/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()
Get Gatt client capabilities.
Function returns bit mask with Gatt client capabilities
- Parameters
-
| [in] | gatt_client | client instance |
- Returns
- bit mask with Gatt client capabilities
◆ gatt_client_get_event_state()
Get event state.
Functions reads CCC descriptor of Service Changed characteristic.
- Parameters
-
| [in] | gatt_client | client instance |
| [in] | event | event type |
- Returns
- true if read request to CCC descriptor has been sent successfully, false otherwise.
◆ gatt_client_init()
Register GATT Client instance.
Function registers GATT Client
- Parameters
-
| [in] | cb | application callbacks |
| [in] | evt | browse 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_idx | connection index |
| [in] | cb | application callbacks |
| [in] | data | data buffer |
| [in] | length | data buffer's length |
- Returns
- client instance when initialized properly, NULL otherwise
◆ gatt_client_set_event_state()
Set event state.
Function enable/disable indications/notifications for given characteristic
- Parameters
-
| [in] | gatt_client | client instance |
| [in] | event | event type |
| [in] | enable | enable/disable flag |
- Returns
- true if write request to CCC descriptor has been sent successfully, false otherwise.