1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
39
40
41
42
43
44
45
46
47
48
49
50
51
52
61
62
63
64
73
86
87
96
97
98
99
100
101
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
201
202
203
204
205
208
209
210
211
212
213
214
215
216
217
218
221
222
223
241
246
247
248
249
250
251
252
253
254
255
259
260
261
262
263
264
265
266
269
270
271
272
273
274
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
378
379
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
416
417
418
419
420
422
423
424
425
426
427
428
430
431
432
433
435
436
437
438
439
440
441
442
443
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
585
586
587
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
649
650
651
652
653
654
657
658
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
689
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
713
714
720
721
722
723
724
725
726
729
730
731
734
735
736
737
738
743
744
745
746
747
748
749
750
751
752
753
754
755
756
760
761
762
763
764
765
766
767
768
769
770
774
775
776
777
778
779
780
781
782
783
784
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
810
811
817
818
819
820
821
822
823
/* ... */
#include "common/bt_target.h"
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE)
#include "common/bt_defs.h"
#include "osi/allocator.h"
#include <string.h>
#include "gap_int.h"
#include "stack/gap_api.h"
#include "stack/gattdefs.h"
#include "stack/gatt_api.h"
#include "gatt_int.h"
#include "btm_int.h"
#include "stack/hcimsgs.h"
#include "stack/sdpdefs.h"11 includes
#define GAP_CHAR_ICON_SIZE 2
#define GAP_CHAR_DEV_NAME_SIZE 248
#define GAP_MAX_NUM_INC_SVR 0
#define GAP_MAX_ATTR_NUM (2 * GAP_MAX_CHAR_NUM + GAP_MAX_NUM_INC_SVR + 1)
#define GAP_MAX_CHAR_VALUE_SIZE (30 + GAP_CHAR_DEV_NAME_SIZE)5 defines
#ifndef GAP_ATTR_DB_SIZE
#define GAP_ATTR_DB_SIZE GATT_DB_MEM_SIZE(GAP_MAX_NUM_INC_SVR, GAP_MAX_CHAR_NUM, GAP_MAX_CHAR_VALUE_SIZE)
#endif
static void gap_ble_s_attr_request_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE op_code, tGATTS_DATA *p_data);
static void gap_ble_c_connect_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id, BOOLEAN connected,
tGATT_DISCONN_REASON reason, tGATT_TRANSPORT transport);
static void gap_ble_c_cmpl_cback (UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS status, tGATT_CL_COMPLETE *p_data);
static const tGATT_CBACK gap_cback = {
gap_ble_c_connect_cback,
gap_ble_c_cmpl_cback,
NULL,
NULL,
gap_ble_s_attr_request_cback,
NULL,
NULL
}{...};
/* ... */
tGAP_CLCB *gap_find_clcb_by_bd_addr(BD_ADDR bda)
{
UINT8 i_clcb;
tGAP_CLCB *p_clcb = NULL;
for (i_clcb = 0, p_clcb = gap_cb.clcb; i_clcb < GAP_MAX_CL; i_clcb++, p_clcb++) {
if (p_clcb->in_use && !memcmp(p_clcb->bda, bda, BD_ADDR_LEN)) {
return p_clcb;
}{...}
}{...}
return NULL;
}{ ... }
/* ... */
tGAP_CLCB *gap_ble_find_clcb_by_conn_id(UINT16 conn_id)
{
UINT8 i_clcb;
tGAP_CLCB *p_clcb = NULL;
for (i_clcb = 0, p_clcb = gap_cb.clcb; i_clcb < GAP_MAX_CL; i_clcb++, p_clcb++) {
if (p_clcb->in_use && p_clcb->connected && p_clcb->conn_id == conn_id) {
return p_clcb;
}{...}
}{...}
return p_clcb;
}{ ... }
/* ... */
tGAP_CLCB *gap_clcb_alloc (BD_ADDR bda)
{
UINT8 i_clcb = 0;
tGAP_CLCB *p_clcb = NULL;
for (i_clcb = 0, p_clcb = gap_cb.clcb; i_clcb < GAP_MAX_CL; i_clcb++, p_clcb++) {
if (!p_clcb->in_use) {
memset(p_clcb, 0, sizeof(tGAP_CLCB));
p_clcb->in_use = TRUE;
memcpy (p_clcb->bda, bda, BD_ADDR_LEN);
break;
}{...}
}{...}
return p_clcb;
}{ ... }
/* ... */
void gap_ble_dealloc_clcb(tGAP_CLCB *p_clcb)
{
tGAP_BLE_REQ *p_q;
while ((p_q = (tGAP_BLE_REQ *)fixed_queue_dequeue(p_clcb->pending_req_q, 0)) != NULL) {
if (p_q->p_cback != NULL) {
(*p_q->p_cback)(FALSE, p_clcb->bda, 0, NULL);
}{...}
osi_free (p_q);
}{...}
memset(p_clcb, 0, sizeof(tGAP_CLCB));
}{ ... }
/* ... */
BOOLEAN gap_ble_enqueue_request (tGAP_CLCB *p_clcb, UINT16 uuid, tGAP_BLE_CMPL_CBACK *p_cback)
{
tGAP_BLE_REQ *p_q = (tGAP_BLE_REQ *)osi_malloc(sizeof(tGAP_BLE_REQ));
if (p_q != NULL) {
p_q->p_cback = p_cback;
p_q->uuid = uuid;
fixed_queue_enqueue(p_clcb->pending_req_q, p_q, FIXED_QUEUE_MAX_TIMEOUT);
return TRUE;
}{...}
return FALSE;
}{ ... }
/* ... */
BOOLEAN gap_ble_dequeue_request (tGAP_CLCB *p_clcb, UINT16 *p_uuid, tGAP_BLE_CMPL_CBACK **p_cback)
{
tGAP_BLE_REQ *p_q = (tGAP_BLE_REQ *)fixed_queue_dequeue(p_clcb->pending_req_q, 0);;
if (p_q != NULL) {
*p_cback = p_q->p_cback;
*p_uuid = p_q->uuid;
osi_free((void *)p_q);
return TRUE;
}{...}
return FALSE;
}{ ... }
/* ... */
tGATT_STATUS gap_read_attr_value (UINT16 handle, tGATT_VALUE *p_value, BOOLEAN is_long)
{
tGAP_ATTR *p_db_attr = gap_cb.gap_attr;
UINT8 *p = p_value->value, i;
UINT16 offset = p_value->offset;
UINT8 *p_dev_name = NULL;
for (i = 0; i < GAP_MAX_CHAR_NUM; i ++, p_db_attr ++) {
if (handle == p_db_attr->handle) {
if (p_db_attr->uuid != GATT_UUID_GAP_DEVICE_NAME &&
is_long == TRUE) {
return GATT_NOT_LONG;
}{...}
switch (p_db_attr->uuid) {
case GATT_UUID_GAP_DEVICE_NAME:
BTM_ReadLocalDeviceName((char **)&p_dev_name, BT_DEVICE_TYPE_BLE);
if (strlen ((char *)p_dev_name) > GATT_MAX_ATTR_LEN) {
p_value->len = GATT_MAX_ATTR_LEN;
}{...} else {
p_value->len = (UINT16)strlen ((char *)p_dev_name);
}{...}
if (offset > p_value->len) {
return GATT_INVALID_OFFSET;
}{...} else {
p_value->len -= offset;
p_dev_name += offset;
ARRAY_TO_STREAM(p, p_dev_name, p_value->len);
GAP_TRACE_EVENT("GATT_UUID_GAP_DEVICE_NAME len=0x%04x", p_value->len);
}{...}
break;
...
case GATT_UUID_GAP_ICON:
UINT16_TO_STREAM(p, p_db_attr->attr_value.icon);
p_value->len = 2;
break;
...
case GATT_UUID_GAP_PREF_CONN_PARAM:
UINT16_TO_STREAM(p, p_db_attr->attr_value.conn_param.int_min);
UINT16_TO_STREAM(p, p_db_attr->attr_value.conn_param.int_max);
UINT16_TO_STREAM(p, p_db_attr->attr_value.conn_param.latency);
UINT16_TO_STREAM(p, p_db_attr->attr_value.conn_param.sp_tout);
p_value->len = 8;
break;
...
case GATT_UUID_GAP_CENTRAL_ADDR_RESOL:
UINT8_TO_STREAM(p, p_db_attr->attr_value.addr_resolution);
p_value->len = 1;
break;...
}{...}
return GATT_SUCCESS;
}{...}
}{...}
return GATT_NOT_FOUND;
}{ ... }
/* ... */
tGATT_STATUS gap_proc_read (tGATTS_REQ_TYPE type, tGATT_READ_REQ *p_data, tGATTS_RSP *p_rsp)
{
tGATT_STATUS status = GATT_NO_RESOURCES;
UNUSED(type);
if (p_data->is_long) {
p_rsp->attr_value.offset = p_data->offset;
}{...}
p_rsp->attr_value.handle = p_data->handle;
status = gap_read_attr_value(p_data->handle, &p_rsp->attr_value, p_data->is_long);
return status;
}{ ... }
/* ... */
UINT8 gap_proc_write_req( tGATTS_REQ_TYPE type, tGATT_WRITE_REQ *p_data)
{
tGAP_ATTR *p_db_attr = gap_cb.gap_attr;
UINT8 i;
UNUSED(type);
for (i = 0; i < GAP_MAX_CHAR_NUM; i ++, p_db_attr ++) {
if (p_data->handle == p_db_attr->handle) {
switch (p_db_attr->uuid) {
#if (GATTS_DEVICE_NAME_WRITABLE == TRUE)
case GATT_UUID_GAP_DEVICE_NAME: {
UINT8 *p_val = p_data->value;
p_val[p_data->len] = '\0';
BTM_SetLocalDeviceName((char *)p_val, BT_DEVICE_TYPE_BLE);
return GATT_SUCCESS;
}{...}
/* ... */ #endif
#if (GATTS_APPEARANCE_WRITABLE == TRUE)
case GATT_UUID_GAP_ICON: {
UINT8 *p_val = p_data->value;
if (p_data->len != sizeof(UINT16)) {
return GATT_INVALID_ATTR_LEN;
}{...}
STREAM_TO_UINT16(p_db_attr->attr_value.icon, p_val);
return GATT_SUCCESS;
}{...}
/* ... */ #endif
default:
break;...
}{...}
return GATT_WRITE_NOT_PERMIT;
}{...}
}{...}
return GATT_NOT_FOUND;
}{ ... }
/* ... */
void gap_ble_s_attr_request_cback (UINT16 conn_id, UINT32 trans_id,
tGATTS_REQ_TYPE type, tGATTS_DATA *p_data)
{
UINT8 status = GATT_INVALID_PDU;
tGATTS_RSP rsp_msg;
BOOLEAN ignore = FALSE;
GAP_TRACE_EVENT("gap_ble_s_attr_request_cback : recv type (0x%02x)", type);
memset(&rsp_msg, 0, sizeof(tGATTS_RSP));
switch (type) {
case GATTS_REQ_TYPE_READ:
status = gap_proc_read(type, &p_data->read_req, &rsp_msg);
break;
...
case GATTS_REQ_TYPE_WRITE:
if (!p_data->write_req.need_rsp) {
ignore = TRUE;
}{...}
status = gap_proc_write_req(type, &p_data->write_req);
break;
...
case GATTS_REQ_TYPE_WRITE_EXEC:
ignore = TRUE;
GAP_TRACE_EVENT("Ignore GATTS_REQ_TYPE_WRITE_EXEC" );
break;
...
case GATTS_REQ_TYPE_MTU:
GAP_TRACE_EVENT("Get MTU exchange new mtu size: %d", p_data->mtu);
ignore = TRUE;
break;
...
default:
GAP_TRACE_EVENT("Unknown/unexpected LE GAP ATT request: 0x%02x", type);
break;...
}{...}
if (!ignore) {
GATTS_SendRsp (conn_id, trans_id, status, &rsp_msg);
}{...}
}{ ... }
/* ... */
void gap_attr_db_init(void)
{
tBT_UUID app_uuid = {LEN_UUID_128, {0}};
tBT_UUID uuid = {LEN_UUID_16, {UUID_SERVCLASS_GAP_SERVER}};
UINT16 service_handle;
tGAP_ATTR *p_db_attr = &gap_cb.gap_attr[0];
tGATT_STATUS status;
memset (&app_uuid.uu.uuid128, 0x82, LEN_UUID_128);
memset(gap_cb.gap_attr, 0, sizeof(tGAP_ATTR) *GAP_MAX_CHAR_NUM);
gap_cb.gatt_if = GATT_Register(&app_uuid, &gap_cback);
GATT_StartIf(gap_cb.gatt_if);
service_handle = GATTS_CreateService (gap_cb.gatt_if, &uuid, 0, GAP_MAX_ATTR_NUM, TRUE);
GAP_TRACE_EVENT ("gap_attr_db_init service_handle = %d", service_handle);
/* ... */
uuid.len = LEN_UUID_16;
uuid.uu.uuid16 = p_db_attr->uuid = GATT_UUID_GAP_DEVICE_NAME;
p_db_attr->handle = GATTS_AddCharacteristic(service_handle, &uuid,
#if (GATTS_DEVICE_NAME_WRITABLE == TRUE)
GATT_PERM_READ | GATT_PERM_WRITE,
GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_WRITE_NR,/* ... */
#else
GATT_PERM_READ, GATT_CHAR_PROP_BIT_READ,
#endif
NULL, NULL);
p_db_attr ++;
/* ... */
uuid.uu.uuid16 = p_db_attr->uuid = GATT_UUID_GAP_ICON;
p_db_attr->handle = GATTS_AddCharacteristic(service_handle, &uuid,
#if (GATTS_APPEARANCE_WRITABLE == TRUE)
GATT_PERM_READ | GATT_PERM_WRITE,
GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_WRITE_NR,/* ... */
#else
GATT_PERM_READ, GATT_CHAR_PROP_BIT_READ,
#endif
NULL, NULL);
p_db_attr ++;
#if ((defined BTM_PERIPHERAL_ENABLED) && (BTM_PERIPHERAL_ENABLED == TRUE))
/* ... */
uuid.uu.uuid16 = p_db_attr->uuid = GATT_UUID_GAP_PREF_CONN_PARAM;
p_db_attr->attr_value.conn_param.int_max = GAP_PREFER_CONN_INT_MAX;
p_db_attr->attr_value.conn_param.int_min = GAP_PREFER_CONN_INT_MIN;
p_db_attr->attr_value.conn_param.latency = GAP_PREFER_CONN_LATENCY;
p_db_attr->attr_value.conn_param.sp_tout = GAP_PREFER_CONN_SP_TOUT;
p_db_attr->handle = GATTS_AddCharacteristic(service_handle,
&uuid,
GATT_PERM_READ,
GATT_CHAR_PROP_BIT_READ,
NULL, NULL);
p_db_attr ++;/* ... */
#endif
uuid.len = LEN_UUID_16;
uuid.uu.uuid16 = p_db_attr->uuid = GATT_UUID_GAP_CENTRAL_ADDR_RESOL;
p_db_attr->handle = GATTS_AddCharacteristic(service_handle, &uuid,
GATT_PERM_READ, GATT_CHAR_PROP_BIT_READ,
NULL, NULL);
p_db_attr->attr_value.addr_resolution = 0;
p_db_attr++;
memset (&app_uuid.uu.uuid128, 0x81, LEN_UUID_128);
status = GATTS_StartService(gap_cb.gatt_if, service_handle, GAP_TRANSPORT_SUPPORTED );
#if (CONFIG_BT_STACK_NO_LOG)
(void) status;
#endif
GAP_TRACE_EVENT ("GAP App gatt_if: %d s_hdl = %d start_status=%d",
gap_cb.gatt_if, service_handle, status);
}{ ... }
/* ... */
void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value)
{
tGAP_ATTR *p_db_attr = gap_cb.gap_attr;
UINT8 i = 0;
GAP_TRACE_EVENT("GAP_BleAttrDBUpdate attr_uuid=0x%04x\n", attr_uuid);
for (i = 0; i < GAP_MAX_CHAR_NUM; i ++, p_db_attr ++) {
if (p_db_attr->uuid == attr_uuid) {
GAP_TRACE_EVENT("Found attr_uuid=0x%04x\n", attr_uuid);
switch (attr_uuid) {
case GATT_UUID_GAP_ICON:
p_db_attr->attr_value.icon = p_value->icon;
break;
...
case GATT_UUID_GAP_PREF_CONN_PARAM:
memcpy((void *)&p_db_attr->attr_value.conn_param,
(const void *)&p_value->conn_param, sizeof(tGAP_BLE_PREF_PARAM));
break;
...
case GATT_UUID_GAP_DEVICE_NAME:
BTM_SetLocalDeviceName((char *)p_value->p_dev_name, BT_DEVICE_TYPE_BLE);
break;
...
case GATT_UUID_GAP_CENTRAL_ADDR_RESOL:
p_db_attr->attr_value.addr_resolution = p_value->addr_resolution;
break;
...
}{...}
break;
}{...}
}{...}
return;
}{ ... }
/* ... */
BOOLEAN gap_ble_send_cl_read_request(tGAP_CLCB *p_clcb)
{
tGATT_READ_PARAM param;
UINT16 uuid = 0;
BOOLEAN started = FALSE;
if (gap_ble_dequeue_request(p_clcb, &uuid, &p_clcb->p_cback)) {
memset(¶m, 0, sizeof(tGATT_READ_PARAM));
param.service.uuid.len = LEN_UUID_16;
param.service.uuid.uu.uuid16 = uuid;
param.service.s_handle = 1;
param.service.e_handle = 0xFFFF;
param.service.auth_req = 0;
#if (GATTC_INCLUDED == TRUE)
if (GATTC_Read(p_clcb->conn_id, GATT_READ_BY_TYPE, ¶m) == GATT_SUCCESS) {
p_clcb->cl_op_uuid = uuid;
started = TRUE;
}{...}
#endif/* ... */
}{...}
return started;
}{ ... }
/* ... */
void gap_ble_cl_op_cmpl(tGAP_CLCB *p_clcb, BOOLEAN status, UINT16 len, UINT8 *p_name)
{
tGAP_BLE_CMPL_CBACK *p_cback = p_clcb->p_cback;
UINT16 op = p_clcb->cl_op_uuid;
GAP_TRACE_EVENT("gap_ble_cl_op_cmpl status: %d", status);
p_clcb->cl_op_uuid = 0;
p_clcb->p_cback = NULL;
if (p_cback && op) {
GAP_TRACE_EVENT("calling gap_ble_cl_op_cmpl");
(* p_cback)(status, p_clcb->bda, len, (char *)p_name);
}{...}
if (p_clcb->connected) {
if (!gap_ble_send_cl_read_request(p_clcb)) {
GATT_Disconnect(p_clcb->conn_id);
gap_ble_dealloc_clcb(p_clcb);
}{...}
}{...}
}{ ... }
/* ... */
static void gap_ble_c_connect_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
BOOLEAN connected, tGATT_DISCONN_REASON reason,
tGATT_TRANSPORT transport)
{
tGAP_CLCB *p_clcb = gap_find_clcb_by_bd_addr (bda);
UNUSED(gatt_if);
UNUSED(transport);
if (p_clcb != NULL) {
if (connected) {
p_clcb->conn_id = conn_id;
p_clcb->connected = TRUE;
gap_ble_send_cl_read_request(p_clcb);
}{...} else {
p_clcb->connected = FALSE;
gap_ble_cl_op_cmpl(p_clcb, FALSE, 0, NULL);
gap_ble_dealloc_clcb(p_clcb);
}{...}
}{...}
}{ ... }
/* ... */
static void gap_ble_c_cmpl_cback (UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS status, tGATT_CL_COMPLETE *p_data)
{
tGAP_CLCB *p_clcb = gap_ble_find_clcb_by_conn_id(conn_id);
UINT16 op_type;
UINT16 min, max, latency, tout;
UINT16 len;
UINT8 *pp;
if (p_clcb == NULL) {
return;
}{...}
op_type = p_clcb->cl_op_uuid;
GAP_TRACE_EVENT ("gap_ble_c_cmpl_cback() - op_code: 0x%02x status: 0x%02x read_type: 0x%04x\n", op, status, op_type);
if (op != GATTC_OPTYPE_READ) {
return;
}{...}
if (status != GATT_SUCCESS) {
gap_ble_cl_op_cmpl(p_clcb, FALSE, 0, NULL);
return;
}{...}
pp = p_data->att_value.value;
switch (op_type) {
case GATT_UUID_GAP_PREF_CONN_PARAM:
GAP_TRACE_EVENT ("GATT_UUID_GAP_PREF_CONN_PARAM");
STREAM_TO_UINT16 (min, pp);
STREAM_TO_UINT16 (max, pp);
STREAM_TO_UINT16 (latency, pp);
STREAM_TO_UINT16 (tout, pp);
BTM_BleSetPrefConnParams (p_clcb->bda, min, max, latency, tout);
gap_ble_cl_op_cmpl(p_clcb, TRUE, 0, NULL);
break;
...
case GATT_UUID_GAP_DEVICE_NAME:
GAP_TRACE_EVENT ("GATT_UUID_GAP_DEVICE_NAME\n");
len = (UINT16)strlen((char *)pp);
if (len > GAP_CHAR_DEV_NAME_SIZE) {
len = GAP_CHAR_DEV_NAME_SIZE;
}{...}
gap_ble_cl_op_cmpl(p_clcb, TRUE, len, pp);
break;
...
case GATT_UUID_GAP_CENTRAL_ADDR_RESOL:
gap_ble_cl_op_cmpl(p_clcb, TRUE, 1, pp);
break;...
}{...}
}{ ... }
/* ... */
BOOLEAN gap_ble_accept_cl_operation(BD_ADDR peer_bda, UINT16 uuid, tGAP_BLE_CMPL_CBACK *p_cback)
{
tGAP_CLCB *p_clcb;
BOOLEAN started = FALSE;
if (p_cback == NULL && uuid != GATT_UUID_GAP_PREF_CONN_PARAM) {
return (started);
}{...}
if ((p_clcb = gap_find_clcb_by_bd_addr (peer_bda)) == NULL) {
if ((p_clcb = gap_clcb_alloc(peer_bda)) == NULL) {
GAP_TRACE_ERROR("gap_ble_accept_cl_operation max connection reached");
return started;
}{...}
}{...}
GAP_TRACE_EVENT ("%s() - BDA: %08x%04x cl_op_uuid: 0x%04x",
__FUNCTION__,
(peer_bda[0] << 24) + (peer_bda[1] << 16) + (peer_bda[2] << 8) + peer_bda[3],
(peer_bda[4] << 8) + peer_bda[5], uuid);
if (GATT_GetConnIdIfConnected(gap_cb.gatt_if, peer_bda, &p_clcb->conn_id, BT_TRANSPORT_LE)) {
p_clcb->connected = TRUE;
}{...}
if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BT_TRANSPORT_LE, FALSE)) {
return started;
}{...}
gap_ble_enqueue_request(p_clcb, uuid, p_cback);
if (p_clcb->connected && p_clcb->cl_op_uuid == 0) {
started = gap_ble_send_cl_read_request(p_clcb);
}{...} else {
started = TRUE;
}{...}
return started;
}{ ... }
/* ... */
BOOLEAN GAP_BleReadPeerPrefConnParams (BD_ADDR peer_bda)
{
return gap_ble_accept_cl_operation (peer_bda, GATT_UUID_GAP_PREF_CONN_PARAM, NULL);
}{ ... }
/* ... */
BOOLEAN GAP_BleReadPeerDevName (BD_ADDR peer_bda, tGAP_BLE_CMPL_CBACK *p_cback)
{
return gap_ble_accept_cl_operation (peer_bda, GATT_UUID_GAP_DEVICE_NAME, p_cback);
}{ ... }
/* ... */
BOOLEAN GAP_BleReadPeerAddressResolutionCap (BD_ADDR peer_bda, tGAP_BLE_CMPL_CBACK *p_cback)
{
return gap_ble_accept_cl_operation(peer_bda, GATT_UUID_GAP_CENTRAL_ADDR_RESOL, p_cback);
}{ ... }
/* ... */
BOOLEAN GAP_BleCancelReadPeerDevName (BD_ADDR peer_bda)
{
tGAP_CLCB *p_clcb = gap_find_clcb_by_bd_addr (peer_bda);
GAP_TRACE_EVENT ("GAP_BleCancelReadPeerDevName() - BDA: %08x%04x cl_op_uuid: 0x%04x",
(peer_bda[0] << 24) + (peer_bda[1] << 16) + (peer_bda[2] << 8) + peer_bda[3],
(peer_bda[4] << 8) + peer_bda[5], (p_clcb == NULL) ? 0 : p_clcb->cl_op_uuid);
if (p_clcb == NULL) {
GAP_TRACE_ERROR ("Cannot cancel current op is not get dev name");
return FALSE;
}{...}
if (!p_clcb->connected) {
if (!GATT_CancelConnect(gap_cb.gatt_if, peer_bda, TRUE)) {
GAP_TRACE_ERROR ("Cannot cancel where No connection id");
return FALSE;
}{...}
}{...}
gap_ble_cl_op_cmpl(p_clcb, FALSE, 0, NULL);
return (TRUE);
}{ ... }
/* ... */#endif