ble_prf.h
Go to the documentation of this file.
1
49 #ifndef __BLE_PRF_H__
50 #define __BLE_PRF_H__
51
52 #include "ble_error.h"
53 #include "ble_att.h"
54 #include "ble_gatts.h"
55 #include "ble_gattc.h"
56 #include "ble_gatt.h"
57
58
77 typedef uint8_t (*prf_init_func_t)(void);
78
86 typedef void (*prf_on_connect_func_t)(uint8_t conn_idx);
87
96 typedef void (*prf_on_disconnect_func_t)(uint8_t conn_idx, uint8_t reason);
97
104 typedef struct
105 {
106 prf_init_func_t init;
107 prf_on_connect_func_t on_connect;
108 prf_on_disconnect_func_t on_disconnect;
109 } ble_prf_manager_cbs_t;
110
127 typedef struct
128 {
129 uint16_t handle;
130 } gatts_read_req_cb_t;
131
135 typedef struct
136 {
137 uint16_t handle;
138 uint16_t offset;
139 uint16_t length;
140 uint8_t value[__ARRAY_EMPTY];
141 } gatts_write_req_cb_t;
142
146 typedef struct
147 {
148 uint16_t handle;
149 } gatts_prep_write_req_cb_t;
150
154 typedef struct
155 {
156 gatt_evt_type_t type;
157 uint16_t handle;
158 } ble_gatts_ntf_ind_t;
159
163 typedef struct
164 {
165 void (*app_gatts_read_cb)(uint8_t conidx, const gatts_read_req_cb_t *p_read_req);
167 void (*app_gatts_write_cb)(uint8_t conidx, const gatts_write_req_cb_t *p_write_req);
169 void (*app_gatts_prep_write_cb)(uint8_t conidx, const gatts_prep_write_req_cb_t *p_prep_req);
171 void (*app_gatts_ntf_ind_cb)(uint8_t conidx, uint8_t status, const ble_gatts_ntf_ind_t *p_ntf_ind);
173 void (*app_gatts_cccd_set_cb)(uint8_t conidx, uint16_t handle, uint16_t cccd_val);
175 } gatts_prf_cbs_t;
176
180 typedef struct
181 {
182 uint16_t max_connection_nb;
183 ble_prf_manager_cbs_t* manager_cbs;
184 gatts_prf_cbs_t *gatts_prf_cbs;
185 } prf_server_info_t;
186
206 uint16_t ble_server_prf_add(const prf_server_info_t *p_server_prf_info);
225 typedef struct
226 {
227 uint16_t start_hdl;
228 uint16_t end_hdl;
229 }gattc_prf_reg_peer_evt_t;
230
234 typedef enum
235 {
236 GATTC_EVT_REGISTER,
237 GATTC_EVT_UNREGISTER,
238 }gattc_prf_reg_evt_t;
239
240
242 typedef struct
243 {
244 void (*app_gattc_srvc_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_srvc_disc_t * p_prim_srvc_disc);
245 void (*app_gattc_inc_srvc_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_incl_disc_t * p_inc_srvc_disc);
246 void (*app_gattc_char_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_char_disc_t * p_char_disc);
247 void (*app_gattc_char_desc_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_char_desc_disc_t *p_char_desc_disc);
248 void (*app_gattc_read_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_read_rsp_t *p_read_rsp);
249 void (*app_gattc_write_cb)(uint8_t conn_idx, uint8_t status, uint16_t handle);
250 void (*app_gattc_ntf_ind_cb)(uint8_t conn_idx, const ble_gattc_ntf_ind_t *p_ntf_ind);
251 void (*app_gattc_srvc_browse_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_browse_srvc_t *p_browse_srvc);
252 void (*app_gattc_prf_reg_cb)(uint8_t conn_idx, uint8_t status, gattc_prf_reg_evt_t reg_evt);
253 } gattc_prf_cbs_t;
254
258 typedef struct
259 {
260 uint16_t max_connection_nb;
261 ble_prf_manager_cbs_t *manager_cbs;
262 gattc_prf_cbs_t *gattc_prf_cbs;
263 } prf_client_info_t;
264
288 uint16_t ble_client_prf_add(const prf_client_info_t *p_client_prf_info, uint8_t *p_client_prf_id);
289
290
319 uint16_t ble_gattc_prf_services_browse(uint8_t prf_id, uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
320
339 uint16_t ble_gattc_prf_primary_services_discover(uint8_t prf_id, uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
340
358 uint16_t ble_gattc_prf_included_services_discover(uint8_t prf_id, uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl);
359
377 uint16_t ble_gattc_prf_char_discover(uint8_t prf_id, uint8_t conn_idx, gattc_disc_char_t *p_disc_char);
378
397 uint16_t ble_gattc_prf_char_desc_discover(uint8_t prf_id, uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl);
398
421 uint16_t ble_gattc_prf_read(uint8_t prf_id, uint8_t conn_idx, uint16_t handle, uint16_t offset);
422
440 uint16_t ble_gattc_prf_read_by_uuid(uint8_t prf_id, uint8_t conn_idx, gattc_read_by_uuid_t *p_read_by_uuid);
441
458 uint16_t ble_gattc_prf_read_multiple(uint8_t prf_id, uint8_t conn_idx, const gattc_read_multiple_t *p_param);
459
482 uint16_t ble_gattc_prf_write(uint8_t prf_id, uint8_t conn_idx, gattc_write_attr_value_t *p_write_attr_value);
483
500 uint16_t ble_gattc_prf_write_prepare(uint8_t prf_id, uint8_t conn_idx, gattc_write_attr_value_t *p_write_attr_value);
501
518 uint16_t ble_gattc_prf_write_execute(uint8_t prf_id, uint8_t conn_idx, bool execute);
519
541 uint16_t ble_gattc_prf_write_no_resp(uint8_t prf_id, uint8_t conn_idx, gattc_write_no_resp_t *p_write_no_resp);
542
559 uint16_t ble_gattc_prf_indicate_cfm(uint8_t prf_id, uint8_t conn_idx, uint16_t handle);
560
561
582 uint16_t ble_gattc_prf_evt_handle_register(uint8_t prf_id, uint8_t conn_idx, gattc_prf_reg_peer_evt_t *env);
583
602 uint16_t ble_gattc_prf_evt_handle_unregister(uint8_t prf_id, uint8_t conn_idx, gattc_prf_reg_peer_evt_t *env);
603
607 #endif
608
ble_gattc_prf_read
uint16_t ble_gattc_prf_read(uint8_t prf_id, uint8_t conn_idx, uint16_t handle, uint16_t offset)
Profile client Read Attribute from remote GATT server.
ble_gatts_ntf_ind_t
GATTS Operation Complete event structure.
Definition: ble_prf.h:155
ble_gattc_ntf_ind_t
GATTC Notification and Indication value indication.
Definition: ble_gattc.h:284
ble_gatts_ntf_ind_t::type
gatt_evt_type_t type
Definition: ble_prf.h:156
prf_server_info_t::max_connection_nb
uint16_t max_connection_nb
Definition: ble_prf.h:182
gattc_write_no_resp_t
GATTC write without response structure.
Definition: ble_gattc.h:121
gattc_read_multiple_t
GATTC Read Multiple.
Definition: ble_gattc.h:137
prf_client_info_t::max_connection_nb
uint16_t max_connection_nb
Definition: ble_prf.h:260
ble_gattc_prf_write_prepare
uint16_t ble_gattc_prf_write_prepare(uint8_t prf_id, uint8_t conn_idx, gattc_write_attr_value_t *p_write_attr_value)
Profile client Prepare Long/Reliable Write to remote GATT server.
__ARRAY_EMPTY
#define __ARRAY_EMPTY
Definition: gr55xx_sys_cfg.h:57
gattc_write_attr_value_t
GATTC write attribute value structure.
Definition: ble_gattc.h:110
gatts_read_req_cb_t::handle
uint16_t handle
Definition: ble_prf.h:129
ble_gattc_prf_read_by_uuid
uint16_t ble_gattc_prf_read_by_uuid(uint8_t prf_id, uint8_t conn_idx, gattc_read_by_uuid_t *p_read_by_uuid)
Profile client Read Attribute by UUID.
ble_gattc_srvc_disc_t
GATT service discovery.
Definition: ble_gattc.h:232
prf_on_connect_func_t
void(* prf_on_connect_func_t)(uint8_t conn_idx)
Handles Connection creation. There is no need to recovery CCCD because stack will do that.
Definition: ble_prf.h:86
ble_prf_manager_cbs_t
Profile manager callbacks.
Definition: ble_prf.h:105
prf_client_info_t
Profile client register information structure.
Definition: ble_prf.h:259
ble_gattc_prf_evt_handle_unregister
uint16_t ble_gattc_prf_evt_handle_unregister(uint8_t prf_id, uint8_t conn_idx, gattc_prf_reg_peer_evt_t *env)
Profile client Unregister Indication/Notification event.
ble_gattc_char_disc_t
GATT characteristic discovery.
Definition: ble_gattc.h:246
prf_on_disconnect_func_t
void(* prf_on_disconnect_func_t)(uint8_t conn_idx, uint8_t reason)
Handles Disconnection. There is no need to recovery CCCD because stack will do that.
Definition: ble_prf.h:96
prf_server_info_t::manager_cbs
ble_prf_manager_cbs_t * manager_cbs
Definition: ble_prf.h:183
GATTC_EVT_REGISTER
@ GATTC_EVT_REGISTER
Definition: ble_prf.h:236
ble_gattc_prf_primary_services_discover
uint16_t ble_gattc_prf_primary_services_discover(uint8_t prf_id, uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid)
Profile client Discover Primary Services on remote GATT server.
ble_prf_manager_cbs_t::on_connect
prf_on_connect_func_t on_connect
Definition: ble_prf.h:107
ble_gatts.h
BLE GATTS API.
gattc_read_by_uuid_t
GATTC read by characteristic UUID structure.
Definition: ble_gattc.h:100
ble_prf_manager_cbs_t::on_disconnect
prf_on_disconnect_func_t on_disconnect
Definition: ble_prf.h:108
ble_gattc_prf_write
uint16_t ble_gattc_prf_write(uint8_t prf_id, uint8_t conn_idx, gattc_write_attr_value_t *p_write_attr_value)
Profile client Write (Long) Characteristic (Descriptor) Value.
ble_gattc_prf_write_no_resp
uint16_t ble_gattc_prf_write_no_resp(uint8_t prf_id, uint8_t conn_idx, gattc_write_no_resp_t *p_write_no_resp)
Profile client Write Attribute to remote GATT server (without response).
gattc_disc_char_t
GATTC discovery characteristic structure.
Definition: ble_gattc.h:90
prf_client_info_t::gattc_prf_cbs
gattc_prf_cbs_t * gattc_prf_cbs
Definition: ble_prf.h:262
ble_gattc_prf_indicate_cfm
uint16_t ble_gattc_prf_indicate_cfm(uint8_t prf_id, uint8_t conn_idx, uint16_t handle)
Profile client Confirm Reception of Indication.
ble_gatt.h
BLE GATT.
gatt_evt_type_t
gatt_evt_type_t
GATT common events.
Definition: ble_gatt.h:67
ble_gattc_prf_read_multiple
uint16_t ble_gattc_prf_read_multiple(uint8_t prf_id, uint8_t conn_idx, const gattc_read_multiple_t *p_param)
Profile client Initiate a Read Multiple Characteristic Values procedure.
GATTC_EVT_UNREGISTER
@ GATTC_EVT_UNREGISTER
Definition: ble_prf.h:237
gatts_read_req_cb_t
GATT read request struct.
Definition: ble_prf.h:128
prf_init_func_t
uint8_t(* prf_init_func_t)(void)
Initialization of the Profile module.
Definition: ble_prf.h:77
ble_gattc_browse_srvc_t
GATTC Browse service(s) indication.
Definition: ble_gattc.h:182
prf_server_info_t
Profile server register information structure.
Definition: ble_prf.h:181
ble_gattc_prf_included_services_discover
uint16_t ble_gattc_prf_included_services_discover(uint8_t prf_id, uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl)
Profile client Discover Included Services on remote GATT server.
ble_server_prf_add
uint16_t ble_server_prf_add(const prf_server_info_t *p_server_prf_info)
Add a server profile by providing its detailed information, including manager callback functions and ...
ble_gattc_prf_char_discover
uint16_t ble_gattc_prf_char_discover(uint8_t prf_id, uint8_t conn_idx, gattc_disc_char_t *p_disc_char)
Profile client Discover Characteristics on remote GATT server.
ble_gattc_incl_disc_t
GATT include discovery.
Definition: ble_gattc.h:239
ble_gattc_char_desc_disc_t
GATT characteristic descriptor discovery.
Definition: ble_gattc.h:253
ble_error.h
File that contains error codes.
gattc_prf_reg_peer_evt_t::start_hdl
uint16_t start_hdl
Definition: ble_prf.h:227
ble_gattc_prf_evt_handle_register
uint16_t ble_gattc_prf_evt_handle_register(uint8_t prf_id, uint8_t conn_idx, gattc_prf_reg_peer_evt_t *env)
Profile client Register Indication/Notification event.
gattc_prf_reg_peer_evt_t
GATTC profile register to peer event info structure.
Definition: ble_prf.h:226
gatts_write_req_cb_t::handle
uint16_t handle
Definition: ble_prf.h:137
gatts_write_req_cb_t::offset
uint16_t offset
Definition: ble_prf.h:138
gatts_prep_write_req_cb_t
GATT prepare write request struct.
Definition: ble_prf.h:147
prf_server_info_t::gatts_prf_cbs
gatts_prf_cbs_t * gatts_prf_cbs
Definition: ble_prf.h:184
gattc_prf_reg_peer_evt_t::end_hdl
uint16_t end_hdl
Definition: ble_prf.h:228
gatts_prep_write_req_cb_t::handle
uint16_t handle
Definition: ble_prf.h:148
gattc_prf_reg_evt_t
gattc_prf_reg_evt_t
GATTC profile register enumeration.
Definition: ble_prf.h:235
ble_client_prf_add
uint16_t ble_client_prf_add(const prf_client_info_t *p_client_prf_info, uint8_t *p_client_prf_id)
Add a client profile by providing its detail information, including manager callback functions and GA...
ble_prf_manager_cbs_t::init
prf_init_func_t init
Definition: ble_prf.h:106
ble_gattc_prf_write_execute
uint16_t ble_gattc_prf_write_execute(uint8_t prf_id, uint8_t conn_idx, bool execute)
Profile client Execute Reliable/Long Write to remote GATT server.
gatts_write_req_cb_t::length
uint16_t length
Definition: ble_prf.h:139
ble_att.h
Attribute Protocol.
ble_gatts_ntf_ind_t::handle
uint16_t handle
Definition: ble_prf.h:157
gatts_prf_cbs_t
GATT server callback function in relation to a profile.
Definition: ble_prf.h:164
ble_gattc.h
BLE GATTC API.
prf_client_info_t::manager_cbs
ble_prf_manager_cbs_t * manager_cbs
Definition: ble_prf.h:261
ble_uuid_t
GATT UUID structure.
Definition: ble_gatt.h:80
ble_gattc_prf_char_desc_discover
uint16_t ble_gattc_prf_char_desc_discover(uint8_t prf_id, uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl)
Profile client Discover Characteristics Descriptors on remote GATT server.
ble_gattc_read_rsp_t
GATT value Read response.
Definition: ble_gattc.h:269
ble_gattc_prf_services_browse
uint16_t ble_gattc_prf_services_browse(uint8_t prf_id, uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid)
Profile client Browse Specific Primary Service information on remote GATT server.
gattc_prf_cbs_t
GATTC Profile callback Structures.
Definition: ble_prf.h:243
gatts_write_req_cb_t
GATT write request struct.
Definition: ble_prf.h:136