ble_gattc.h
Go to the documentation of this file.
1
55 #ifndef __BLE_GATTC_H__
56 #define __BLE_GATTC_H__
57
58 #include "ble_error.h"
59 #include "ble_gatt.h"
60 #include "ble_att.h"
61 #include "gr55xx_sys_cfg.h"
62
63 #include <stdint.h>
64 #include <stdbool.h>
65
72 typedef enum
73 {
74 BLE_GATTC_BROWSE_NONE,
75 BLE_GATTC_BROWSE_INC_SRVC,
76 BLE_GATTC_BROWSE_ATTR_CHAR,
77 BLE_GATTC_BROWSE_ATTR_VAL,
78 BLE_GATTC_BROWSE_ATTR_DESC,
79 } gatt_attr_t;
80
89 typedef struct
90 {
91 uint16_t start_hdl;
92 uint16_t end_hdl;
93 ble_uuid_t *p_uuid;
94 } gattc_disc_char_t;
95
99 typedef struct
100 {
101 uint16_t start_hdl;
102 uint16_t end_hdl;
103 ble_uuid_t *p_uuid;
104 } gattc_read_by_uuid_t;
105
109 typedef struct
110 {
111 uint16_t handle;
112 uint16_t offset;
113 uint16_t length;
114 uint8_t *p_value;
115 } gattc_write_attr_value_t;
116
120 typedef struct
121 {
122 bool signed_write;
123 uint16_t handle;
124 uint16_t length;
125 uint8_t *p_value;
126 } gattc_write_no_resp_t;
127
129 typedef struct
130 {
131 uint16_t handle;
132 uint16_t len;
133 } read_multiple_t;
134
136 typedef struct
137 {
138 uint16_t handle_count;
139 read_multiple_t *p_read_multiple;
140 } gattc_read_multiple_t;
141
142
144 typedef struct
145 {
146 uint8_t attr_type;
147 uint8_t prop;
148 uint16_t handle;
149 uint8_t uuid_len;
150 uint8_t uuid[BLE_ATT_UUID_128_LEN];
151 } gattc_browse_attr_char_t;
152
154 typedef struct
155 {
156 uint8_t attr_type;
157 uint8_t uuid_len;
158 uint8_t uuid[BLE_ATT_UUID_128_LEN];
159 uint16_t start_hdl;
160 uint16_t end_hdl;
161 } gattc_browse_inc_srvc_t;
162
164 typedef struct
165 {
166 uint8_t attr_type;
167 uint8_t uuid_len;
168 uint8_t uuid[BLE_ATT_UUID_128_LEN];
169 } gattc_browse_attr_t;
170
172 union gattc_browse_attr_info
173 {
174 uint8_t attr_type;
175 gattc_browse_attr_char_t attr_char;
176 gattc_browse_inc_srvc_t inc_srvc;
177 gattc_browse_attr_t attr;
178 };
179
181 typedef struct
182 {
183 uint8_t uuid_len;
184 uint8_t uuid[BLE_ATT_UUID_128_LEN];
185 uint16_t start_hdl;
186 uint16_t end_hdl;
187 union gattc_browse_attr_info info[__ARRAY_EMPTY];
189 } ble_gattc_browse_srvc_t;
190
191
192
194 typedef struct
195 {
196 uint16_t start_hdl;
197 uint16_t end_hdl;
198 uint8_t uuid_len;
199 uint8_t *p_uuid;
200 } ble_gattc_service_t;
201
203 typedef struct
204 {
205 uint16_t attr_hdl;
206 uint16_t start_hdl;
207 uint16_t end_hdl;
208 uint8_t uuid_len;
209 uint8_t *p_uuid;
210 } ble_gattc_include_t;
211
213 typedef struct
214 {
215 uint16_t handle_decl;
216 uint16_t handle_value;
217 uint8_t prop;
218 uint8_t uuid_len;
219 uint8_t *p_uuid;
220 } ble_gattc_char_t;
221
223 typedef struct
224 {
225 uint16_t attr_hdl;
226 uint8_t uuid_len;
227 uint8_t *p_uuid;
228 } ble_gattc_desc_t;
229
231 typedef struct
232 {
233 uint16_t count;
234 ble_gattc_service_t services[__ARRAY_EMPTY];
235 }ble_gattc_srvc_disc_t;
236
238 typedef struct
239 {
240 uint16_t count;
241 ble_gattc_include_t includes[__ARRAY_EMPTY];
242 }ble_gattc_incl_disc_t;
243
245 typedef struct
246 {
247 uint16_t count;
248 ble_gattc_char_t chars[__ARRAY_EMPTY];
249 }ble_gattc_char_disc_t;
250
252 typedef struct
253 {
254 uint16_t count;
255 ble_gattc_desc_t char_descs[__ARRAY_EMPTY];
256 }ble_gattc_char_desc_disc_t;
257
259 typedef struct
260 {
261 uint16_t handle;
262 uint16_t offset;
263 uint16_t length;
264 uint8_t *p_value;
265 } ble_gattc_read_value_t;
266
268 typedef struct
269 {
270 uint16_t count;
271 ble_gattc_read_value_t vals[__ARRAY_EMPTY];
272 }ble_gattc_read_rsp_t;
273
274
276 typedef struct
277 {
278 uint16_t handle;
279 } ble_gattc_write_t;
280
281
283 typedef struct
284 {
285 gatt_evt_type_t type;
286 uint16_t length;
287 uint16_t handle;
288 uint8_t *p_value;
289 } ble_gattc_ntf_ind_t;
290
292 typedef struct
293 {
294 void (*app_gattc_srvc_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_srvc_disc_t * p_prim_srvc_disc);
295 void (*app_gattc_inc_srvc_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_incl_disc_t * p_inc_srvc_disc);
296 void (*app_gattc_char_disc_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_char_disc_t * p_char_disc);
297 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);
298 void (*app_gattc_read_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_read_rsp_t *p_read_rsp);
299 void (*app_gattc_write_cb)(uint8_t conn_idx, uint8_t status, uint16_t handle);
300 void (*app_gattc_ntf_ind_cb)(uint8_t conn_idx, const ble_gattc_ntf_ind_t *p_ntf_ind);
301 void (*app_gattc_srvc_browse_cb)(uint8_t conn_idx, uint8_t status, const ble_gattc_browse_srvc_t *p_browse_srvc);
302 } gattc_cb_fun_t;
321 uint16_t ble_gattc_mtu_exchange(uint8_t conn_idx);
322
342 uint16_t ble_gattc_services_browse(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
343
358 uint16_t ble_gattc_primary_services_discover(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid);
359
374 uint16_t ble_gattc_included_services_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl);
375
390 uint16_t ble_gattc_char_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl, const ble_uuid_t *p_char_uuid);
391
408 uint16_t ble_gattc_char_desc_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl);
409
429 uint16_t ble_gattc_read(uint8_t conn_idx, uint16_t handle, uint16_t offset);
430
448 uint16_t ble_gattc_read_by_uuid(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl, const ble_uuid_t *p_char_uuid);
449
464 uint16_t ble_gattc_read_multiple(uint8_t conn_idx, const gattc_read_multiple_t *p_param);
465
489 uint16_t ble_gattc_write(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value);
490
509 uint16_t ble_gattc_write_prepare(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value);
510
525 uint16_t ble_gattc_write_execute(uint8_t conn_idx, bool execute);
526
549 uint16_t ble_gattc_write_no_resp(uint8_t conn_idx, bool signed_write, uint16_t handle, uint16_t length, const uint8_t *p_value);
550
565 uint16_t ble_gattc_indicate_cfm(uint8_t conn_idx, uint16_t handle);
566
569 #endif
570
gattc_browse_attr_char_t::prop
uint8_t prop
Definition: ble_gattc.h:147
ble_gattc_ntf_ind_t
GATTC Notification and Indication value indication.
Definition: ble_gattc.h:284
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
read_multiple_t::handle
uint16_t handle
Definition: ble_gattc.h:131
read_multiple_t::len
uint16_t len
Definition: ble_gattc.h:132
__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
BLE_GATTC_BROWSE_ATTR_VAL
@ BLE_GATTC_BROWSE_ATTR_VAL
Definition: ble_gattc.h:77
read_multiple_t
Read Multiple Handles.
Definition: ble_gattc.h:130
gattc_browse_attr_info::attr_char
gattc_browse_attr_char_t attr_char
Definition: ble_gattc.h:175
BLE_ATT_UUID_128_LEN
#define BLE_ATT_UUID_128_LEN
Definition: ble_att.h:65
gattc_write_attr_value_t::offset
uint16_t offset
Definition: ble_gattc.h:112
ble_gattc_srvc_disc_t
GATT service discovery.
Definition: ble_gattc.h:232
ble_gattc_char_disc_t::count
uint16_t count
Definition: ble_gattc.h:247
ble_gattc_char_t::handle_value
uint16_t handle_value
Definition: ble_gattc.h:216
BLE_GATTC_BROWSE_NONE
@ BLE_GATTC_BROWSE_NONE
Definition: ble_gattc.h:74
ble_gattc_read_multiple
uint16_t ble_gattc_read_multiple(uint8_t conn_idx, const gattc_read_multiple_t *p_param)
Initiate a Read Multiple Characteristic Values procedure.
ble_gattc_service_t::p_uuid
uint8_t * p_uuid
Definition: ble_gattc.h:199
ble_gattc_write_prepare
uint16_t ble_gattc_write_prepare(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value)
Prepare Long/Reliable Write to remote GATT server.
gattc_browse_attr_t::attr_type
uint8_t attr_type
Definition: ble_gattc.h:166
gattc_browse_attr_info::attr_type
uint8_t attr_type
Definition: ble_gattc.h:174
gattc_cb_fun_t
GATTC Event callback Structures.
Definition: ble_gattc.h:293
ble_gattc_included_services_discover
uint16_t ble_gattc_included_services_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl)
Discover Included Services on remote GATT server.
gattc_read_multiple_t::p_read_multiple
read_multiple_t * p_read_multiple
Definition: ble_gattc.h:139
ble_gattc_char_disc_t
GATT characteristic discovery.
Definition: ble_gattc.h:246
ble_gattc_include_t::end_hdl
uint16_t end_hdl
Definition: ble_gattc.h:207
gattc_write_no_resp_t::signed_write
bool signed_write
Definition: ble_gattc.h:122
ble_gattc_char_desc_discover
uint16_t ble_gattc_char_desc_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl)
Discover Characteristics Descriptors on remote GATT server.
gatt_attr_t
gatt_attr_t
GATT Client Service Discover Attribute type IDs.
Definition: ble_gattc.h:73
BLE_GATTC_BROWSE_ATTR_CHAR
@ BLE_GATTC_BROWSE_ATTR_CHAR
Definition: ble_gattc.h:76
ble_gattc_char_t::handle_decl
uint16_t handle_decl
Definition: ble_gattc.h:215
gattc_read_by_uuid_t
GATTC read by characteristic UUID structure.
Definition: ble_gattc.h:100
ble_gattc_ntf_ind_t::length
uint16_t length
Definition: ble_gattc.h:286
ble_gattc_mtu_exchange
uint16_t ble_gattc_mtu_exchange(uint8_t conn_idx)
Perform MTU Exchange.
ble_gattc_desc_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:226
ble_gattc_service_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:198
ble_gattc_char_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:218
gattc_disc_char_t
GATTC discovery characteristic structure.
Definition: ble_gattc.h:90
gattc_browse_attr_info
GATTC Browse attribute information.
Definition: ble_gattc.h:173
ble_gattc_services_browse
uint16_t ble_gattc_services_browse(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid)
Browse all Primary Services or specific Primary Service information on remote GATT server.
gattc_browse_inc_srvc_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:159
gattc_read_by_uuid_t::end_hdl
uint16_t end_hdl
Definition: ble_gattc.h:102
ble_gatt.h
BLE GATT.
gatt_evt_type_t
gatt_evt_type_t
GATT common events.
Definition: ble_gatt.h:67
gattc_disc_char_t::end_hdl
uint16_t end_hdl
Definition: ble_gattc.h:92
gr55xx_sys_cfg.h
Define the chip configuration.
ble_gattc_browse_srvc_t
GATTC Browse service(s) indication.
Definition: ble_gattc.h:182
ble_gattc_char_t
GATT characteristic.
Definition: ble_gattc.h:214
ble_gattc_read_value_t
GATT Client Read value.
Definition: ble_gattc.h:260
gattc_write_no_resp_t::p_value
uint8_t * p_value
Definition: ble_gattc.h:125
ble_gattc_browse_srvc_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:183
ble_gattc_incl_disc_t
GATT include discovery.
Definition: ble_gattc.h:239
BLE_GATTC_BROWSE_INC_SRVC
@ BLE_GATTC_BROWSE_INC_SRVC
Definition: ble_gattc.h:75
gattc_write_attr_value_t::handle
uint16_t handle
Definition: ble_gattc.h:111
gattc_browse_attr_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:167
ble_gattc_char_desc_disc_t
GATT characteristic descriptor discovery.
Definition: ble_gattc.h:253
ble_gattc_char_t::prop
uint8_t prop
Definition: ble_gattc.h:217
ble_error.h
File that contains error codes.
ble_gattc_service_t::end_hdl
uint16_t end_hdl
Definition: ble_gattc.h:197
gattc_browse_inc_srvc_t::end_hdl
uint16_t end_hdl
Definition: ble_gattc.h:160
ble_gattc_write
uint16_t ble_gattc_write(uint8_t conn_idx, uint16_t handle, uint16_t offset, uint16_t length, const uint8_t *p_value)
Write (long) Characteristic (Descriptor) Value.
gattc_write_attr_value_t::p_value
uint8_t * p_value
Definition: ble_gattc.h:114
ble_gattc_include_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:208
ble_gattc_primary_services_discover
uint16_t ble_gattc_primary_services_discover(uint8_t conn_idx, const ble_uuid_t *p_srvc_uuid)
Discover Primary Services on remote GATT server.
gattc_write_attr_value_t::length
uint16_t length
Definition: ble_gattc.h:113
ble_gattc_write_no_resp
uint16_t ble_gattc_write_no_resp(uint8_t conn_idx, bool signed_write, uint16_t handle, uint16_t length, const uint8_t *p_value)
Write Attribute to remote GATT server (without response).
ble_gattc_read_value_t::offset
uint16_t offset
Definition: ble_gattc.h:262
ble_gattc_desc_t
GATT descriptor.
Definition: ble_gattc.h:224
gattc_write_no_resp_t::length
uint16_t length
Definition: ble_gattc.h:124
gattc_disc_char_t::p_uuid
ble_uuid_t * p_uuid
Definition: ble_gattc.h:93
ble_gattc_srvc_disc_t::count
uint16_t count
Definition: ble_gattc.h:233
ble_gattc_write_t::handle
uint16_t handle
Definition: ble_gattc.h:278
ble_gattc_service_t
GATT service.
Definition: ble_gattc.h:195
ble_gattc_read
uint16_t ble_gattc_read(uint8_t conn_idx, uint16_t handle, uint16_t offset)
Read Attribute from remote GATT server.
gattc_browse_attr_char_t
GATTC Browse information about Characteristic.
Definition: ble_gattc.h:145
ble_gattc_browse_srvc_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:185
ble_gattc_char_discover
uint16_t ble_gattc_char_discover(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl, const ble_uuid_t *p_char_uuid)
Discover Characteristics on remote GATT server.
gattc_browse_inc_srvc_t::attr_type
uint8_t attr_type
Definition: ble_gattc.h:156
gattc_read_by_uuid_t::p_uuid
ble_uuid_t * p_uuid
Definition: ble_gattc.h:103
ble_gattc_read_value_t::p_value
uint8_t * p_value
Definition: ble_gattc.h:264
ble_gattc_ntf_ind_t::handle
uint16_t handle
Definition: ble_gattc.h:287
ble_gattc_desc_t::p_uuid
uint8_t * p_uuid
Definition: ble_gattc.h:227
ble_gattc_include_t
GATT include.
Definition: ble_gattc.h:204
ble_gattc_indicate_cfm
uint16_t ble_gattc_indicate_cfm(uint8_t conn_idx, uint16_t handle)
Confirm Reception of Indication.
BLE_GATTC_BROWSE_ATTR_DESC
@ BLE_GATTC_BROWSE_ATTR_DESC
Definition: ble_gattc.h:78
ble_gattc_ntf_ind_t::type
gatt_evt_type_t type
Definition: ble_gattc.h:285
ble_gattc_char_t::p_uuid
uint8_t * p_uuid
Definition: ble_gattc.h:219
gattc_browse_inc_srvc_t
GATTC Browse information about Included Service.
Definition: ble_gattc.h:155
gattc_browse_attr_char_t::attr_type
uint8_t attr_type
Definition: ble_gattc.h:146
gattc_read_by_uuid_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:101
ble_gattc_incl_disc_t::count
uint16_t count
Definition: ble_gattc.h:240
gattc_browse_attr_info::attr
gattc_browse_attr_t attr
Definition: ble_gattc.h:177
ble_att.h
Attribute Protocol.
gattc_browse_attr_info::inc_srvc
gattc_browse_inc_srvc_t inc_srvc
Definition: ble_gattc.h:176
ble_gattc_write_t
GATT Client Write.
Definition: ble_gattc.h:277
gattc_write_no_resp_t::handle
uint16_t handle
Definition: ble_gattc.h:123
ble_gattc_include_t::p_uuid
uint8_t * p_uuid
Definition: ble_gattc.h:209
gattc_disc_char_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:91
ble_uuid_t
GATT UUID structure.
Definition: ble_gatt.h:80
gattc_browse_attr_t
GATTC Browse information about Attribute.
Definition: ble_gattc.h:165
gattc_browse_attr_char_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:149
ble_gattc_read_rsp_t
GATT value Read response.
Definition: ble_gattc.h:269
ble_gattc_read_by_uuid
uint16_t ble_gattc_read_by_uuid(uint8_t conn_idx, uint16_t start_hdl, uint16_t end_hdl, const ble_uuid_t *p_char_uuid)
Read Attribute by UUID.
ble_gattc_char_desc_disc_t::count
uint16_t count
Definition: ble_gattc.h:254
gattc_read_multiple_t::handle_count
uint16_t handle_count
Definition: ble_gattc.h:138
gattc_browse_inc_srvc_t::uuid_len
uint8_t uuid_len
Definition: ble_gattc.h:157
ble_gattc_include_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:206
ble_gattc_desc_t::attr_hdl
uint16_t attr_hdl
Definition: ble_gattc.h:225
ble_gattc_include_t::attr_hdl
uint16_t attr_hdl
Definition: ble_gattc.h:205
gattc_browse_attr_char_t::handle
uint16_t handle
Definition: ble_gattc.h:148
ble_gattc_read_value_t::length
uint16_t length
Definition: ble_gattc.h:263
ble_gattc_read_value_t::handle
uint16_t handle
Definition: ble_gattc.h:261
ble_gattc_ntf_ind_t::p_value
uint8_t * p_value
Definition: ble_gattc.h:288
ble_gattc_write_execute
uint16_t ble_gattc_write_execute(uint8_t conn_idx, bool execute)
Execute Reliable/Long Write to remote GATT server.
ble_gattc_read_rsp_t::count
uint16_t count
Definition: ble_gattc.h:270
ble_gattc_service_t::start_hdl
uint16_t start_hdl
Definition: ble_gattc.h:196