SmartSnippets DA1459x SDK
ble_client.h
Go to the documentation of this file.
1 
43 #ifndef BLE_CLIENT_H_
44 #define BLE_CLIENT_H_
45 
46 #include <stdbool.h>
47 #include "ble_gattc.h"
48 #include "ble_gap.h"
49 
50 typedef struct ble_client ble_client_t;
51 
61 typedef void (* read_completed_evt_t) (ble_client_t *client,
63 
73 typedef void (* write_completed_evt_t) (ble_client_t *client,
75 
85 typedef void (* notification_evt_t) (ble_client_t *client,
86  const ble_evt_gattc_notification_t *evt);
87 
97 typedef void (* indication_evt_t) (ble_client_t *client, const ble_evt_gattc_indication_t *evt);
98 
108 typedef void (* disconnect_evt_t) (ble_client_t *client, const ble_evt_gap_disconnected_t *evt);
109 
129 typedef void (* serialize_cb_t) (ble_client_t *client, void *data, size_t *length);
130 
139 typedef void (* attach_cb_t) (ble_client_t *client);
140 
149 typedef void (* cleanup_cb_t) (ble_client_t *client);
150 
154 typedef struct ble_client {
155  uint16_t conn_idx;
157  uint16_t start_h;
158  uint16_t end_h;
169 } ble_client_t;
170 
179 void ble_client_add(ble_client_t *client);
180 
189 void ble_client_remove(const ble_client_t *client);
190 
199 void ble_client_cleanup(ble_client_t *client);
200 
207 void ble_clients_cleanup(void);
208 
226 void ble_client_serialize(ble_client_t *client, void *data, size_t *length);
227 
237 void ble_client_attach(ble_client_t *client, uint16_t conn_idx);
238 
247 void ble_client_handle_event(const ble_evt_hdr_t *evt);
248 
261 __STATIC_INLINE bool ble_client_in_range(const ble_client_t *client, uint16_t start_h, uint16_t end_h)
262 {
263  return (client && (client->end_h >= start_h) && (client->start_h <= end_h));
264 }
265 
266 #endif /* BLE_CLIENT_H_ */
267 
read_completed_evt_t
void(* read_completed_evt_t)(ble_client_t *client, const ble_evt_gattc_read_completed_t *evt)
Read completed callback.
Definition: ble_client.h:61
ble_client::notification_evt
notification_evt_t notification_evt
Definition: ble_client.h:162
ble_client_cleanup
void ble_client_cleanup(ble_client_t *client)
Cleanup client.
ble_client_serialize
void ble_client_serialize(ble_client_t *client, void *data, size_t *length)
Serialize client.
ble_client_remove
void ble_client_remove(const ble_client_t *client)
Remove client.
indication_evt_t
void(* indication_evt_t)(ble_client_t *client, const ble_evt_gattc_indication_t *evt)
Indication callback.
Definition: ble_client.h:97
ble_client_add
void ble_client_add(ble_client_t *client)
Add client.
ble_client::disconnected_evt
disconnect_evt_t disconnected_evt
Definition: ble_client.h:164
ble_client::write_completed_evt
write_completed_evt_t write_completed_evt
Definition: ble_client.h:161
ble_evt_gattc_read_completed_t
Definition: ble_gattc.h:181
ble_client::attach
attach_cb_t attach
Definition: ble_client.h:167
ble_client::end_h
uint16_t end_h
Definition: ble_client.h:158
ble_client::read_completed_evt
read_completed_evt_t read_completed_evt
Definition: ble_client.h:160
disconnect_evt_t
void(* disconnect_evt_t)(ble_client_t *client, const ble_evt_gap_disconnected_t *evt)
Disconnected callback.
Definition: ble_client.h:108
ble_evt_gap_disconnected_t
Definition: ble_gap.h:597
notification_evt_t
void(* notification_evt_t)(ble_client_t *client, const ble_evt_gattc_notification_t *evt)
Notification callback.
Definition: ble_client.h:85
ble_client
Definition: ble_client.h:154
serialize_cb_t
void(* serialize_cb_t)(ble_client_t *client, void *data, size_t *length)
Serialize callback.
Definition: ble_client.h:129
ble_client_attach
void ble_client_attach(ble_client_t *client, uint16_t conn_idx)
Attach client.
ble_evt_hdr_t
Definition: ble_common.h:156
cleanup_cb_t
void(* cleanup_cb_t)(ble_client_t *client)
Cleanup callback.
Definition: ble_client.h:149
ble_client::indication_evt
indication_evt_t indication_evt
Definition: ble_client.h:163
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.
Definition: ble_client.h:261
ble_client::cleanup
cleanup_cb_t cleanup
Definition: ble_client.h:168
attach_cb_t
void(* attach_cb_t)(ble_client_t *client)
Attach callback.
Definition: ble_client.h:139
ble_client_t
struct ble_client ble_client_t
Definition: ble_client.h:50
ble_evt_gattc_indication_t
Definition: ble_gattc.h:210
ble_client_handle_event
void ble_client_handle_event(const ble_evt_hdr_t *evt)
Handle BLE event.
ble_client::conn_idx
uint16_t conn_idx
Definition: ble_client.h:155
ble_client::serialize
serialize_cb_t serialize
Definition: ble_client.h:166
ble_evt_gattc_notification_t
Definition: ble_gattc.h:201
ble_gattc.h
BLE GATT Client API.
write_completed_evt_t
void(* write_completed_evt_t)(ble_client_t *client, const ble_evt_gattc_write_completed_t *evt)
Write completed callback.
Definition: ble_client.h:73
ble_gap.h
BLE GAP API.
ble_clients_cleanup
void ble_clients_cleanup(void)
Cleanup all clients.
ble_evt_gattc_write_completed_t
Definition: ble_gattc.h:192
ble_client::start_h
uint16_t start_h
Definition: ble_client.h:157