1 /******************************************************************************
2 *
3 * Copyright (C) 2008-2012 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 /******************************************************************************
20 *
21 * this file contains the main GATT server attributes access request
22 * handling functions.
23 *
24 ******************************************************************************/
25
26 #include "common/bt_target.h"
27 //#include "bt_utils.h"
28
29 #include "stack/gatt_api.h"
30 #include "gatt_int.h"
31 #include "stack/sdpdefs.h"
32
33 #if (BLE_INCLUDED == 1 && GATTS_INCLUDED == 1)
34
35 #define GATTP_MAX_NUM_INC_SVR 0
36 #define GATTP_MAX_CHAR_NUM 2
37 #define GATTP_MAX_ATTR_NUM (GATTP_MAX_CHAR_NUM * 2 + GATTP_MAX_NUM_INC_SVR + 1)
38 #define GATTP_MAX_CHAR_VALUE_SIZE 50
39
40 #ifndef GATTP_ATTR_DB_SIZE
41 #define GATTP_ATTR_DB_SIZE GATT_DB_MEM_SIZE(GATTP_MAX_NUM_INC_SVR, GATTP_MAX_CHAR_NUM, GATTP_MAX_CHAR_VALUE_SIZE)
42 #endif
43
44 static void gatt_request_cback(UINT16 conn_id, UINT32 trans_id, UINT8 op_code, tGATTS_DATA *p_data);
45 static void gatt_connect_cback(tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id, BOOLEAN connected,
46 tGATT_DISCONN_REASON reason, tBT_TRANSPORT transport);
47 static void gatt_disc_res_cback(UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_DISC_RES *p_data);
48 static void gatt_disc_cmpl_cback(UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status);
49 static void gatt_cl_op_cmpl_cback(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS status,
50 tGATT_CL_COMPLETE *p_data);
51
52 static void gatt_cl_start_config_ccc(tGATT_PROFILE_CLCB *p_clcb);
53
54
55 static const tGATT_CBACK gatt_profile_cback = {
56 gatt_connect_cback,
57 gatt_cl_op_cmpl_cback,
58 gatt_disc_res_cback,
59 gatt_disc_cmpl_cback,
60 gatt_request_cback,
61 NULL,
62 NULL
63 } ;
64
65 /*******************************************************************************
66 **
67 ** Function gatt_profile_find_conn_id_by_bd_addr
68 **
69 ** Description Find the connection ID by remote address
70 **
71 ** Returns Connection ID
72 **
73 *******************************************************************************/
74 #if (GATTS_INCLUDED == 1)
gatt_profile_find_conn_id_by_bd_addr(BD_ADDR remote_bda)75 UINT16 gatt_profile_find_conn_id_by_bd_addr(BD_ADDR remote_bda)
76 {
77 UINT16 conn_id = GATT_INVALID_CONN_ID;
78 GATT_GetConnIdIfConnected (gatt_cb.gatt_if, remote_bda, &conn_id, BT_TRANSPORT_LE);
79 return conn_id;
80 }
81 #endif ///GATTS_INCLUDED == 1
82 /*******************************************************************************
83 **
84 ** Function gatt_profile_find_clcb_by_conn_id
85 **
86 ** Description find clcb by Connection ID
87 **
88 ** Returns Pointer to the found link conenction control block.
89 **
90 *******************************************************************************/
gatt_profile_find_clcb_by_conn_id(UINT16 conn_id)91 static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_conn_id(UINT16 conn_id)
92 {
93 UINT8 i_clcb;
94 tGATT_PROFILE_CLCB *p_clcb = NULL;
95
96 for (i_clcb = 0, p_clcb = gatt_cb.profile_clcb; i_clcb < GATT_MAX_APPS; i_clcb++, p_clcb++) {
97 if (p_clcb->in_use && p_clcb->conn_id == conn_id) {
98 return p_clcb;
99 }
100 }
101
102 return NULL;
103 }
104
105 /*******************************************************************************
106 **
107 ** Function gatt_profile_find_clcb_by_bd_addr
108 **
109 ** Description The function searches all LCBs with macthing bd address.
110 **
111 ** Returns Pointer to the found link conenction control block.
112 **
113 *******************************************************************************/
gatt_profile_find_clcb_by_bd_addr(BD_ADDR bda,tBT_TRANSPORT transport)114 static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_bd_addr(BD_ADDR bda, tBT_TRANSPORT transport)
115 {
116 UINT8 i_clcb;
117 tGATT_PROFILE_CLCB *p_clcb = NULL;
118
119 for (i_clcb = 0, p_clcb = gatt_cb.profile_clcb; i_clcb < GATT_MAX_APPS; i_clcb++, p_clcb++) {
120 if (p_clcb->in_use && p_clcb->transport == transport &&
121 p_clcb->connected && !memcmp(p_clcb->bda, bda, BD_ADDR_LEN)) {
122 return p_clcb;
123 }
124 }
125
126 return NULL;
127 }
128
129 /*******************************************************************************
130 **
131 ** Function gatt_profile_clcb_alloc
132 **
133 ** Description The function allocates a GATT profile connection link control block
134 **
135 ** Returns NULL if not found. Otherwise pointer to the connection link block.
136 **
137 *******************************************************************************/
gatt_profile_clcb_alloc(UINT16 conn_id,BD_ADDR bda,tBT_TRANSPORT tranport)138 tGATT_PROFILE_CLCB *gatt_profile_clcb_alloc (UINT16 conn_id, BD_ADDR bda, tBT_TRANSPORT tranport)
139 {
140 UINT8 i_clcb = 0;
141 tGATT_PROFILE_CLCB *p_clcb = NULL;
142
143 for (i_clcb = 0, p_clcb = gatt_cb.profile_clcb; i_clcb < GATT_MAX_APPS; i_clcb++, p_clcb++) {
144 if (!p_clcb->in_use) {
145 p_clcb->in_use = 1;
146 p_clcb->conn_id = conn_id;
147 p_clcb->connected = 1;
148 p_clcb->transport = tranport;
149 memcpy (p_clcb->bda, bda, BD_ADDR_LEN);
150 break;
151 }
152 }
153 if (i_clcb < GATT_MAX_APPS) {
154 return p_clcb;
155 }
156
157 return NULL;
158 }
159
160 /*******************************************************************************
161 **
162 ** Function gatt_profile_clcb_dealloc
163 **
164 ** Description The function deallocates a GATT profile connection link control block
165 **
166 ** Returns void
167 **
168 *******************************************************************************/
gatt_profile_clcb_dealloc(tGATT_PROFILE_CLCB * p_clcb)169 void gatt_profile_clcb_dealloc (tGATT_PROFILE_CLCB *p_clcb)
170 {
171 memset(p_clcb, 0, sizeof(tGATT_PROFILE_CLCB));
172 }
173
174 /*******************************************************************************
175 **
176 ** Function gatt_proc_read
177 **
178 ** Description GATT Attributes Database Read/Read Blob Request process
179 **
180 ** Returns GATT_SUCCESS if successfully sent; otherwise error code.
181 **
182 *******************************************************************************/
gatt_proc_read(tGATTS_REQ_TYPE type,tGATT_READ_REQ * p_data,tGATTS_RSP * p_rsp)183 tGATT_STATUS gatt_proc_read (tGATTS_REQ_TYPE type, tGATT_READ_REQ *p_data, tGATTS_RSP *p_rsp)
184 {
185 tGATT_STATUS status = GATT_NO_RESOURCES;
186 UNUSED(type);
187
188 if (p_data->is_long) {
189 p_rsp->attr_value.offset = p_data->offset;
190 }
191
192 p_rsp->attr_value.handle = p_data->handle;
193 UINT16 len = 0;
194 uint8_t *value;
195 status = GATTS_GetAttributeValue(p_data->handle, &len, &value);
196 if(status == GATT_SUCCESS && len > 0 && value) {
197 if(len > GATT_MAX_ATTR_LEN) {
198 len = GATT_MAX_ATTR_LEN;
199 }
200 p_rsp->attr_value.len = len;
201 memcpy(p_rsp->attr_value.value, value, len);
202 }
203
204 return status;
205 }
206
207 /******************************************************************************
208 **
209 ** Function gatt_proc_write_req
210 **
211 ** Description GATT server process a write request.
212 **
213 ** Returns GATT_SUCCESS if successfully sent; otherwise error code.
214 **
215 *******************************************************************************/
gatt_proc_write_req(tGATTS_REQ_TYPE type,tGATT_WRITE_REQ * p_data)216 tGATT_STATUS gatt_proc_write_req( tGATTS_REQ_TYPE type, tGATT_WRITE_REQ *p_data)
217 {
218 if(p_data->len > GATT_MAX_ATTR_LEN) {
219 p_data->len = GATT_MAX_ATTR_LEN;
220 }
221 return GATTS_SetAttributeValue(p_data->handle,
222 p_data->len,
223 p_data->value);
224
225 }
226
227 /*******************************************************************************
228 **
229 ** Function gatt_request_cback
230 **
231 ** Description GATT profile attribute access request callback.
232 **
233 ** Returns void.
234 **
235 *******************************************************************************/
gatt_request_cback(UINT16 conn_id,UINT32 trans_id,tGATTS_REQ_TYPE type,tGATTS_DATA * p_data)236 static void gatt_request_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type,
237 tGATTS_DATA *p_data)
238 {
239 UINT8 status = GATT_INVALID_PDU;
240 tGATTS_RSP rsp_msg ;
241 BOOLEAN ignore = 0;
242 GATT_TRACE_DEBUG("%s",__func__);
243 memset(&rsp_msg, 0, sizeof(tGATTS_RSP));
244
245 switch (type) {
246 case GATTS_REQ_TYPE_READ:
247 status = gatt_proc_read(type, &p_data->read_req, &rsp_msg);
248 break;
249
250 case GATTS_REQ_TYPE_WRITE:
251 if (!p_data->write_req.need_rsp) {
252 ignore = 1;
253 }
254 status = gatt_proc_write_req(type, &p_data->write_req);
255 break;
256
257 case GATTS_REQ_TYPE_WRITE_EXEC:
258 case GATT_CMD_WRITE:
259 ignore = 1;
260 GATT_TRACE_EVENT("Ignore GATT_REQ_EXEC_WRITE/WRITE_CMD" );
261 break;
262
263 case GATTS_REQ_TYPE_MTU:
264 GATT_TRACE_EVENT("Get MTU exchange new mtu size: %d", p_data->mtu);
265 ignore = 1;
266 break;
267
268 default:
269 GATT_TRACE_EVENT("Unknown/unexpected LE GAP ATT request: 0x%02x", type);
270 break;
271 }
272
273 if (!ignore) {
274 GATTS_SendRsp (conn_id, trans_id, status, &rsp_msg);
275 }
276
277 }
278
279 /*******************************************************************************
280 **
281 ** Function gatt_connect_cback
282 **
283 ** Description Gatt profile connection callback.
284 **
285 ** Returns void
286 **
287 *******************************************************************************/
gatt_connect_cback(tGATT_IF gatt_if,BD_ADDR bda,UINT16 conn_id,BOOLEAN connected,tGATT_DISCONN_REASON reason,tBT_TRANSPORT transport)288 static void gatt_connect_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
289 BOOLEAN connected, tGATT_DISCONN_REASON reason,
290 tBT_TRANSPORT transport)
291 {
292 UNUSED(gatt_if);
293
294 GATT_TRACE_DEBUG ("%s: from %08x%04x connected:%d conn_id=%d reason = 0x%04x", __FUNCTION__,
295 (bda[0] << 24) + (bda[1] << 16) + (bda[2] << 8) + bda[3],
296 (bda[4] << 8) + bda[5], connected, conn_id, reason);
297
298 tGATT_PROFILE_CLCB *p_clcb = gatt_profile_find_clcb_by_bd_addr(bda, transport);
299 if (p_clcb == NULL) {
300 p_clcb = gatt_profile_clcb_alloc (conn_id, bda, transport);
301 }
302
303 if (p_clcb == NULL) {
304 return;
305 }
306
307 if (GATT_GetConnIdIfConnected (gatt_cb.gatt_if, bda, &p_clcb->conn_id, transport)) {
308 p_clcb->connected = 1;
309 p_clcb->conn_id = conn_id;
310 }
311
312
313 if (!p_clcb->connected) {
314 /* wait for connection */
315 return;
316 }
317
318 if (connected) {
319 p_clcb->conn_id = conn_id;
320 p_clcb->connected = 1;
321
322 } else {
323 gatt_profile_clcb_dealloc(p_clcb);
324 }
325 }
326
327 /*******************************************************************************
328 **
329 ** Function gatt_profile_db_init
330 **
331 ** Description Initializa the GATT profile attribute database.
332 **
333 *******************************************************************************/
gatt_profile_db_init(void)334 void gatt_profile_db_init (void)
335 {
336 tBT_UUID app_uuid = {LEN_UUID_128, {0}};
337 tBT_UUID uuid = {LEN_UUID_16, {UUID_SERVCLASS_GATT_SERVER}};
338 UINT16 service_handle = 0;
339 tGATT_STATUS status;
340
341 /* Fill our internal UUID with a fixed pattern 0x81 */
342 memset (&app_uuid.uu.uuid128, 0x81, LEN_UUID_128);
343
344
345 /* Create a GATT profile service */
346 gatt_cb.gatt_if = GATT_Register(&app_uuid, &gatt_profile_cback);
347 GATT_StartIf(gatt_cb.gatt_if);
348
349 service_handle = GATTS_CreateService (gatt_cb.gatt_if , &uuid, 0, GATTP_MAX_ATTR_NUM, 1);
350 GATT_TRACE_DEBUG ("GATTS_CreateService: handle of service handle%x", service_handle);
351
352 /* add Service Changed characteristic
353 */
354 uuid.uu.uuid16 = gatt_cb.gattp_attr.uuid = GATT_UUID_GATT_SRV_CHGD;
355 gatt_cb.gattp_attr.service_change = 0;
356 gatt_cb.gattp_attr.handle =
357 gatt_cb.handle_of_h_r = GATTS_AddCharacteristic(service_handle, &uuid, 0, GATT_CHAR_PROP_BIT_INDICATE,
358 NULL, NULL);
359
360 GATT_TRACE_DEBUG ("gatt_profile_db_init: handle of service changed%d\n",
361 gatt_cb.handle_of_h_r);
362
363 tBT_UUID descr_uuid = {LEN_UUID_16, {GATT_UUID_CHAR_CLIENT_CONFIG}};
364 uint8_t ccc_value[2] ={ 0x00, 0x00};
365
366 tGATT_ATTR_VAL attr_val = {
367 .attr_max_len = sizeof(UINT16),
368 .attr_len = sizeof(UINT16),
369 .attr_val = ccc_value,
370 };
371
372 GATTS_AddCharDescriptor (service_handle, GATT_PERM_READ | GATT_PERM_WRITE , &descr_uuid, &attr_val, NULL);
373 /* start service
374 */
375 status = GATTS_StartService (gatt_cb.gatt_if, service_handle, GATTP_TRANSPORT_SUPPORTED );
376
377 #if (CONFIG_BT_STACK_NO_LOG)
378 (void) status;
379 #endif
380
381 GATT_TRACE_DEBUG ("gatt_profile_db_init: gatt_if=%d start status%d\n",
382 gatt_cb.gatt_if, status);
383 }
384
385 /*******************************************************************************
386 **
387 ** Function gatt_disc_res_cback
388 **
389 ** Description Gatt profile discovery result callback
390 **
391 ** Returns void
392 **
393 *******************************************************************************/
gatt_disc_res_cback(UINT16 conn_id,tGATT_DISC_TYPE disc_type,tGATT_DISC_RES * p_data)394 static void gatt_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_DISC_RES *p_data)
395 {
396 GATT_TRACE_DEBUG("%s, disc_type = %d",__func__, disc_type);
397 tGATT_PROFILE_CLCB *p_clcb = gatt_profile_find_clcb_by_conn_id(conn_id);
398
399 if (p_clcb == NULL) {
400 return;
401 }
402
403 switch (disc_type) {
404 case GATT_DISC_SRVC_BY_UUID:/* stage 1 */
405 p_clcb->e_handle = p_data->value.group_value.e_handle;
406 p_clcb->ccc_result ++;
407 break;
408
409 case GATT_DISC_CHAR:/* stage 2 */
410 p_clcb->s_handle = p_data->value.dclr_value.val_handle;
411 p_clcb->ccc_result ++;
412 break;
413
414 case GATT_DISC_CHAR_DSCPT: /* stage 3 */
415 if (p_data->type.uu.uuid16 == GATT_UUID_CHAR_CLIENT_CONFIG) {
416 p_clcb->s_handle = p_data->handle;
417 p_clcb->ccc_result ++;
418 }
419 break;
420 }
421 }
422
423 /*******************************************************************************
424 **
425 ** Function gatt_disc_cmpl_cback
426 **
427 ** Description Gatt profile discovery complete callback
428 **
429 ** Returns void
430 **
431 *******************************************************************************/
gatt_disc_cmpl_cback(UINT16 conn_id,tGATT_DISC_TYPE disc_type,tGATT_STATUS status)432 static void gatt_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status)
433 {
434 GATT_TRACE_DEBUG("%s",__func__);
435 tGATT_PROFILE_CLCB *p_clcb = gatt_profile_find_clcb_by_conn_id(conn_id);
436
437 if (p_clcb == NULL) {
438 return;
439 }
440
441 if (status == GATT_SUCCESS && p_clcb->ccc_result > 0) {
442 p_clcb->ccc_result = 0;
443 p_clcb->ccc_stage ++;
444 gatt_cl_start_config_ccc(p_clcb);
445 } else {
446 GATT_TRACE_ERROR("%s() - Register for service changed indication failure", __FUNCTION__);
447 }
448 }
449
450 /*******************************************************************************
451 **
452 ** Function gatt_cl_op_cmpl_cback
453 **
454 ** Description Gatt profile client operation complete callback
455 **
456 ** Returns void
457 **
458 *******************************************************************************/
gatt_cl_op_cmpl_cback(UINT16 conn_id,tGATTC_OPTYPE op,tGATT_STATUS status,tGATT_CL_COMPLETE * p_data)459 static void gatt_cl_op_cmpl_cback (UINT16 conn_id, tGATTC_OPTYPE op,
460 tGATT_STATUS status, tGATT_CL_COMPLETE *p_data)
461 {
462 GATT_TRACE_DEBUG("%s",__func__);
463 tGATT_PROFILE_CLCB *p_clcb = gatt_profile_find_clcb_by_conn_id(conn_id);
464
465 if (p_clcb == NULL) {
466 return;
467 }
468
469 if (op == GATTC_OPTYPE_WRITE) {
470 GATT_TRACE_DEBUG("%s() - ccc write status : %d", __FUNCTION__, status);
471 }
472
473 }
474
475 /*******************************************************************************
476 **
477 ** Function gatt_cl_start_config_ccc
478 **
479 ** Description Gatt profile start configure service change CCC
480 **
481 ** Returns void
482 **
483 *******************************************************************************/
gatt_cl_start_config_ccc(tGATT_PROFILE_CLCB * p_clcb)484 static void gatt_cl_start_config_ccc(tGATT_PROFILE_CLCB *p_clcb)
485 {
486 tGATT_DISC_PARAM srvc_disc_param;
487 tGATT_VALUE ccc_value;
488
489 GATT_TRACE_DEBUG("%s() - stage: %d", __FUNCTION__, p_clcb->ccc_stage);
490
491 memset (&srvc_disc_param, 0 , sizeof(tGATT_DISC_PARAM));
492 memset (&ccc_value, 0 , sizeof(tGATT_VALUE));
493
494 switch (p_clcb->ccc_stage) {
495 case GATT_SVC_CHANGED_SERVICE: /* discover GATT service */
496 srvc_disc_param.s_handle = 1;
497 srvc_disc_param.e_handle = 0xffff;
498 srvc_disc_param.service.len = 2;
499 srvc_disc_param.service.uu.uuid16 = UUID_SERVCLASS_GATT_SERVER;
500 #if (GATTC_INCLUDED == 1)
501 if (GATTC_Discover (p_clcb->conn_id, GATT_DISC_SRVC_BY_UUID, &srvc_disc_param) != GATT_SUCCESS) {
502 GATT_TRACE_ERROR("%s() - ccc service error", __FUNCTION__);
503 }
504 #endif ///GATTC_INCLUDED == 1
505 break;
506
507 case GATT_SVC_CHANGED_CHARACTERISTIC: /* discover service change char */
508 srvc_disc_param.s_handle = 1;
509 srvc_disc_param.e_handle = p_clcb->e_handle;
510 srvc_disc_param.service.len = 2;
511 srvc_disc_param.service.uu.uuid16 = GATT_UUID_GATT_SRV_CHGD;
512 #if (GATTC_INCLUDED == 1)
513 if (GATTC_Discover (p_clcb->conn_id, GATT_DISC_CHAR, &srvc_disc_param) != GATT_SUCCESS) {
514 GATT_TRACE_ERROR("%s() - ccc char error", __FUNCTION__);
515 }
516 #endif ///GATTC_INCLUDED == 1
517 break;
518
519 case GATT_SVC_CHANGED_DESCRIPTOR: /* discover service change ccc */
520 srvc_disc_param.s_handle = p_clcb->s_handle;
521 srvc_disc_param.e_handle = p_clcb->e_handle;
522 #if (GATTC_INCLUDED == 1)
523 if (GATTC_Discover (p_clcb->conn_id, GATT_DISC_CHAR_DSCPT, &srvc_disc_param) != GATT_SUCCESS) {
524 GATT_TRACE_ERROR("%s() - ccc char descriptor error", __FUNCTION__);
525 }
526 #endif ///GATTC_INCLUDED == 1
527 break;
528
529 case GATT_SVC_CHANGED_CONFIGURE_CCCD: /* write ccc */
530 ccc_value.handle = p_clcb->s_handle;
531 ccc_value.len = 2;
532 ccc_value.value[0] = GATT_CLT_CONFIG_INDICATION;
533 #if (GATTC_INCLUDED == 1)
534 if (GATTC_Write (p_clcb->conn_id, GATT_WRITE, &ccc_value) != GATT_SUCCESS) {
535 GATT_TRACE_ERROR("%s() - write ccc error", __FUNCTION__);
536 }
537 #endif ///GATTC_INCLUDED == 1
538 break;
539 }
540 }
541
542 /*******************************************************************************
543 **
544 ** Function GATT_ConfigServiceChangeCCC
545 **
546 ** Description Configure service change indication on remote device
547 **
548 ** Returns none
549 **
550 *******************************************************************************/
GATT_ConfigServiceChangeCCC(BD_ADDR remote_bda,BOOLEAN enable,tBT_TRANSPORT transport)551 void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable, tBT_TRANSPORT transport)
552 {
553 tGATT_PROFILE_CLCB *p_clcb = gatt_profile_find_clcb_by_bd_addr (remote_bda, transport);
554
555 if (p_clcb == NULL) {
556 p_clcb = gatt_profile_clcb_alloc (0, remote_bda, transport);
557 }
558
559 if (p_clcb == NULL) {
560 return;
561 }
562
563 if (GATT_GetConnIdIfConnected (gatt_cb.gatt_if, remote_bda, &p_clcb->conn_id, transport)) {
564 p_clcb->connected = 1;
565 }
566 /* hold the link here */
567 GATT_Connect(gatt_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, 1, transport, 0);
568 p_clcb->ccc_stage = GATT_SVC_CHANGED_CONNECTING;
569
570 if (!p_clcb->connected) {
571 /* wait for connection */
572 return;
573 }
574
575 p_clcb->ccc_stage ++;
576 gatt_cl_start_config_ccc(p_clcb);
577 }
578
579 #endif /* BLE_INCLUDED == 1 && GATTS_INCLUDED == 1 */
580