1 /******************************************************************************
2 *
3 * Copyright 2017 The Android Open Source Project
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 #include <base/logging.h>
20 #include <base/strings/stringprintf.h>
21 #include <string.h>
22 #include <array>
23 #include <list>
24 #include <queue>
25 #include "gap_api.h"
26 #include "gatt_api.h"
27 #include "main/shim/dumpsys.h"
28 #include "osi/include/log.h"
29 #include "types/bt_transport.h"
30
31 using base::StringPrintf;
32 using bluetooth::Uuid;
33
34 namespace {
35
36 typedef struct {
37 uint16_t uuid;
38 tGAP_BLE_CMPL_CBACK* p_cback;
39 } tGAP_REQUEST;
40
41 typedef struct {
42 RawAddress bda;
43 tGAP_BLE_CMPL_CBACK* p_cback;
44 uint16_t conn_id;
45 uint16_t cl_op_uuid;
46 bool connected;
47 std::queue<tGAP_REQUEST> requests;
48 } tGAP_CLCB;
49
50 typedef struct {
51 uint16_t handle;
52 uint16_t uuid;
53 tGAP_BLE_ATTR_VALUE attr_value;
54 } tGAP_ATTR;
55
56 void server_attr_request_cback(uint16_t, uint32_t, tGATTS_REQ_TYPE,
57 tGATTS_DATA*);
58 void client_connect_cback(tGATT_IF, const RawAddress&, uint16_t, bool,
59 tGATT_DISCONN_REASON, tBT_TRANSPORT);
60 void client_cmpl_cback(uint16_t, tGATTC_OPTYPE, tGATT_STATUS,
61 tGATT_CL_COMPLETE*);
62
63 tGATT_CBACK gap_cback = {
64 .p_conn_cb = client_connect_cback,
65 .p_cmpl_cb = client_cmpl_cback,
66 .p_disc_res_cb = nullptr,
67 .p_disc_cmpl_cb = nullptr,
68 .p_req_cb = server_attr_request_cback,
69 .p_enc_cmpl_cb = nullptr,
70 .p_congestion_cb = nullptr,
71 .p_phy_update_cb = nullptr,
72 .p_conn_update_cb = nullptr,
73 };
74
75 constexpr int GAP_CHAR_DEV_NAME_SIZE = BD_NAME_LEN;
76 constexpr int GAP_MAX_CHAR_NUM = 4;
77
78 std::vector<tGAP_CLCB> gap_clcbs;
79 /* LE GAP attribute database */
80 std::array<tGAP_ATTR, GAP_MAX_CHAR_NUM> gatt_attr;
81 tGATT_IF gatt_if;
82
83 /** returns LCB with macthing bd address, or nullptr */
find_clcb_by_bd_addr(const RawAddress & bda)84 tGAP_CLCB* find_clcb_by_bd_addr(const RawAddress& bda) {
85 for (auto& cb : gap_clcbs)
86 if (cb.bda == bda) return &cb;
87
88 return nullptr;
89 }
90
91 /** returns LCB with macthing connection ID, or nullptr if not found */
ble_find_clcb_by_conn_id(uint16_t conn_id)92 tGAP_CLCB* ble_find_clcb_by_conn_id(uint16_t conn_id) {
93 for (auto& cb : gap_clcbs)
94 if (cb.connected && cb.conn_id == conn_id) return &cb;
95
96 return nullptr;
97 }
98
99 /** allocates a GAP connection link control block */
clcb_alloc(const RawAddress & bda)100 tGAP_CLCB* clcb_alloc(const RawAddress& bda) {
101 gap_clcbs.emplace_back();
102 tGAP_CLCB& cb = gap_clcbs.back();
103 cb.bda = bda;
104 return &cb;
105 }
106
107 /** The function clean up the pending request queue in GAP */
clcb_dealloc(tGAP_CLCB & clcb)108 void clcb_dealloc(tGAP_CLCB& clcb) {
109 // put last element into place of current element, and remove last one - just
110 // fast remove.
111 for (auto it = gap_clcbs.begin(); it != gap_clcbs.end(); it++) {
112 if (it->conn_id == clcb.conn_id) {
113 auto last_one = std::prev(gap_clcbs.end());
114 *it = *last_one;
115 gap_clcbs.erase(last_one);
116 return;
117 }
118 }
119 }
120
121 /** GAP Attributes Database Request callback */
read_attr_value(uint16_t handle,tGATT_VALUE * p_value,bool is_long)122 tGATT_STATUS read_attr_value(uint16_t handle, tGATT_VALUE* p_value,
123 bool is_long) {
124 uint8_t* p = p_value->value;
125 uint16_t offset = p_value->offset;
126 uint8_t* p_dev_name = NULL;
127
128 for (const tGAP_ATTR& db_attr : gatt_attr) {
129 const tGAP_BLE_ATTR_VALUE& attr_value = db_attr.attr_value;
130 if (handle == db_attr.handle) {
131 if (db_attr.uuid != GATT_UUID_GAP_DEVICE_NAME && is_long)
132 return GATT_NOT_LONG;
133
134 switch (db_attr.uuid) {
135 case GATT_UUID_GAP_DEVICE_NAME:
136 BTM_ReadLocalDeviceName((char**)&p_dev_name);
137 if (strlen((char*)p_dev_name) > GATT_MAX_ATTR_LEN)
138 p_value->len = GATT_MAX_ATTR_LEN;
139 else
140 p_value->len = (uint16_t)strlen((char*)p_dev_name);
141
142 if (offset > p_value->len)
143 return GATT_INVALID_OFFSET;
144 else {
145 p_value->len -= offset;
146 p_dev_name += offset;
147 ARRAY_TO_STREAM(p, p_dev_name, p_value->len);
148 DVLOG(1) << "GATT_UUID_GAP_DEVICE_NAME len=" << +p_value->len;
149 }
150 break;
151
152 case GATT_UUID_GAP_ICON:
153 UINT16_TO_STREAM(p, attr_value.icon);
154 p_value->len = 2;
155 break;
156
157 case GATT_UUID_GAP_PREF_CONN_PARAM:
158 UINT16_TO_STREAM(p, attr_value.conn_param.int_min); /* int_min */
159 UINT16_TO_STREAM(p, attr_value.conn_param.int_max); /* int_max */
160 UINT16_TO_STREAM(p, attr_value.conn_param.latency); /* latency */
161 UINT16_TO_STREAM(p, attr_value.conn_param.sp_tout); /* sp_tout */
162 p_value->len = 8;
163 break;
164
165 /* address resolution */
166 case GATT_UUID_GAP_CENTRAL_ADDR_RESOL:
167 UINT8_TO_STREAM(p, attr_value.addr_resolution);
168 p_value->len = 1;
169 break;
170 }
171 return GATT_SUCCESS;
172 }
173 }
174 return GATT_NOT_FOUND;
175 }
176
177 /** GAP Attributes Database Read/Read Blob Request process */
proc_read(tGATTS_REQ_TYPE,tGATT_READ_REQ * p_data,tGATTS_RSP * p_rsp)178 tGATT_STATUS proc_read(tGATTS_REQ_TYPE, tGATT_READ_REQ* p_data,
179 tGATTS_RSP* p_rsp) {
180 if (p_data->is_long) p_rsp->attr_value.offset = p_data->offset;
181
182 p_rsp->attr_value.handle = p_data->handle;
183
184 return read_attr_value(p_data->handle, &p_rsp->attr_value, p_data->is_long);
185 }
186
187 /** GAP ATT server process a write request */
proc_write_req(tGATTS_REQ_TYPE,tGATT_WRITE_REQ * p_data)188 tGATT_STATUS proc_write_req(tGATTS_REQ_TYPE, tGATT_WRITE_REQ* p_data) {
189 for (const auto& db_addr : gatt_attr)
190 if (p_data->handle == db_addr.handle) return GATT_WRITE_NOT_PERMIT;
191
192 return GATT_NOT_FOUND;
193 }
194
195 /** GAP ATT server attribute access request callback */
server_attr_request_cback(uint16_t conn_id,uint32_t trans_id,tGATTS_REQ_TYPE type,tGATTS_DATA * p_data)196 void server_attr_request_cback(uint16_t conn_id, uint32_t trans_id,
197 tGATTS_REQ_TYPE type, tGATTS_DATA* p_data) {
198 tGATT_STATUS status = GATT_INVALID_PDU;
199 bool ignore = false;
200
201 DVLOG(1) << StringPrintf("%s: recv type (0x%02x)", __func__, type);
202
203 tGATTS_RSP rsp_msg;
204 memset(&rsp_msg, 0, sizeof(tGATTS_RSP));
205
206 switch (type) {
207 case GATTS_REQ_TYPE_READ_CHARACTERISTIC:
208 case GATTS_REQ_TYPE_READ_DESCRIPTOR:
209 status = proc_read(type, &p_data->read_req, &rsp_msg);
210 break;
211
212 case GATTS_REQ_TYPE_WRITE_CHARACTERISTIC:
213 case GATTS_REQ_TYPE_WRITE_DESCRIPTOR:
214 if (!p_data->write_req.need_rsp) ignore = true;
215
216 status = proc_write_req(type, &p_data->write_req);
217 break;
218
219 case GATTS_REQ_TYPE_WRITE_EXEC:
220 ignore = true;
221 DVLOG(1) << "Ignore GATTS_REQ_TYPE_WRITE_EXEC";
222 break;
223
224 case GATTS_REQ_TYPE_MTU:
225 DVLOG(1) << "Get MTU exchange new mtu size: " << +p_data->mtu;
226 ignore = true;
227 break;
228
229 default:
230 DVLOG(1) << StringPrintf("Unknown/unexpected LE GAP ATT request: 0x%02x",
231 type);
232 break;
233 }
234
235 if (!ignore) GATTS_SendRsp(conn_id, trans_id, status, &rsp_msg);
236 }
237
238 /**
239 * utility function to send a read request for a GAP charactersitic.
240 * Returns true if read started, else false if GAP is busy.
241 */
send_cl_read_request(tGAP_CLCB & clcb)242 bool send_cl_read_request(tGAP_CLCB& clcb) {
243 if (!clcb.requests.size()) {
244 return false;
245 }
246
247 tGAP_REQUEST& req = clcb.requests.front();
248 clcb.p_cback = req.p_cback;
249 uint16_t uuid = req.uuid;
250 clcb.requests.pop();
251
252 tGATT_READ_PARAM param;
253 memset(¶m, 0, sizeof(tGATT_READ_PARAM));
254
255 param.service.uuid = Uuid::From16Bit(uuid);
256 param.service.s_handle = 1;
257 param.service.e_handle = 0xFFFF;
258 param.service.auth_req = 0;
259
260 if (GATTC_Read(clcb.conn_id, GATT_READ_BY_TYPE, ¶m) == GATT_SUCCESS) {
261 clcb.cl_op_uuid = uuid;
262 }
263
264 return true;
265 }
266
267 /** GAP client operation complete callback */
cl_op_cmpl(tGAP_CLCB & clcb,bool status,uint16_t len,uint8_t * p_name)268 void cl_op_cmpl(tGAP_CLCB& clcb, bool status, uint16_t len, uint8_t* p_name) {
269 tGAP_BLE_CMPL_CBACK* p_cback = clcb.p_cback;
270 uint16_t op = clcb.cl_op_uuid;
271
272 DVLOG(1) << StringPrintf("%s: status: %d", __func__, status);
273
274 clcb.cl_op_uuid = 0;
275 clcb.p_cback = NULL;
276
277 if (p_cback && op) {
278 DVLOG(1) << __func__ << ": calling";
279 (*p_cback)(status, clcb.bda, len, (char*)p_name);
280 }
281
282 /* if no further activity is requested in callback, drop the link */
283 if (clcb.connected) {
284 if (!send_cl_read_request(clcb)) {
285 GATT_Disconnect(clcb.conn_id);
286 clcb_dealloc(clcb);
287 }
288 }
289 }
290
291 /** Client connection callback */
client_connect_cback(tGATT_IF,const RawAddress & bda,uint16_t conn_id,bool connected,tGATT_DISCONN_REASON reason,tBT_TRANSPORT)292 void client_connect_cback(tGATT_IF, const RawAddress& bda, uint16_t conn_id,
293 bool connected, tGATT_DISCONN_REASON reason,
294 tBT_TRANSPORT) {
295 tGAP_CLCB* p_clcb = find_clcb_by_bd_addr(bda);
296 if (p_clcb == NULL) {
297 LOG_INFO("No active GAP service found for peer:%s callback:%s",
298 PRIVATE_ADDRESS(bda), (connected) ? "Connected" : "Disconnected");
299 return;
300 }
301
302 if (connected) {
303 LOG_DEBUG("Connected GAP to remote device");
304 p_clcb->conn_id = conn_id;
305 p_clcb->connected = true;
306 /* start operation is pending */
307 send_cl_read_request(*p_clcb);
308 } else {
309 LOG_WARN("Disconnected GAP from remote device");
310 p_clcb->connected = false;
311 cl_op_cmpl(*p_clcb, false, 0, NULL);
312 /* clean up clcb */
313 clcb_dealloc(*p_clcb);
314 }
315 }
316
317 /** Client operation complete callback */
client_cmpl_cback(uint16_t conn_id,tGATTC_OPTYPE op,tGATT_STATUS status,tGATT_CL_COMPLETE * p_data)318 void client_cmpl_cback(uint16_t conn_id, tGATTC_OPTYPE op, tGATT_STATUS status,
319 tGATT_CL_COMPLETE* p_data) {
320 tGAP_CLCB* p_clcb = ble_find_clcb_by_conn_id(conn_id);
321 uint16_t op_type;
322 uint16_t min, max, latency, tout;
323 uint16_t len;
324 uint8_t* pp;
325
326 if (p_clcb == NULL) return;
327
328 op_type = p_clcb->cl_op_uuid;
329
330 DVLOG(1) << StringPrintf(
331 "%s: - op_code: 0x%02x status: 0x%02x read_type: 0x%04x", __func__, op,
332 status, op_type);
333 /* Currently we only issue read commands */
334 if (op != GATTC_OPTYPE_READ) return;
335
336 if (status != GATT_SUCCESS) {
337 cl_op_cmpl(*p_clcb, false, 0, NULL);
338 return;
339 }
340
341 pp = p_data->att_value.value;
342 switch (op_type) {
343 case GATT_UUID_GAP_PREF_CONN_PARAM:
344 /* Extract the peripheral preferred connection parameters and save them */
345 STREAM_TO_UINT16(min, pp);
346 STREAM_TO_UINT16(max, pp);
347 STREAM_TO_UINT16(latency, pp);
348 STREAM_TO_UINT16(tout, pp);
349
350 BTM_BleSetPrefConnParams(p_clcb->bda, min, max, latency, tout);
351 /* release the connection here */
352 cl_op_cmpl(*p_clcb, true, 0, NULL);
353 break;
354
355 case GATT_UUID_GAP_DEVICE_NAME:
356 len = (uint16_t)strlen((char*)pp);
357 if (len > GAP_CHAR_DEV_NAME_SIZE) len = GAP_CHAR_DEV_NAME_SIZE;
358 cl_op_cmpl(*p_clcb, true, len, pp);
359 break;
360
361 case GATT_UUID_GAP_CENTRAL_ADDR_RESOL:
362 cl_op_cmpl(*p_clcb, true, 1, pp);
363 break;
364 }
365 }
366
accept_client_operation(const RawAddress & peer_bda,uint16_t uuid,tGAP_BLE_CMPL_CBACK * p_cback)367 bool accept_client_operation(const RawAddress& peer_bda, uint16_t uuid,
368 tGAP_BLE_CMPL_CBACK* p_cback) {
369 if (p_cback == NULL && uuid != GATT_UUID_GAP_PREF_CONN_PARAM) return false;
370
371 tGAP_CLCB* p_clcb = find_clcb_by_bd_addr(peer_bda);
372 if (p_clcb == NULL) {
373 p_clcb = clcb_alloc(peer_bda);
374 }
375
376 DVLOG(1) << __func__ << ": BDA: " << peer_bda
377 << StringPrintf(" cl_op_uuid: 0x%04x", uuid);
378
379 if (GATT_GetConnIdIfConnected(gatt_if, peer_bda, &p_clcb->conn_id,
380 BT_TRANSPORT_LE))
381 p_clcb->connected = true;
382
383 if (!GATT_Connect(gatt_if, p_clcb->bda, true, BT_TRANSPORT_LE, true))
384 return false;
385
386 /* enqueue the request */
387 p_clcb->requests.push({.uuid = uuid, .p_cback = p_cback});
388
389 if (p_clcb->connected && p_clcb->cl_op_uuid == 0)
390 return send_cl_read_request(*p_clcb);
391 else /* wait for connection up or pending operation to finish */
392 return true;
393 }
394
395 } // namespace
396
397 /*******************************************************************************
398 *
399 * Function btm_ble_att_db_init
400 *
401 * Description GAP ATT database initalization.
402 *
403 * Returns void.
404 *
405 ******************************************************************************/
gap_attr_db_init(void)406 void gap_attr_db_init(void) {
407 uint16_t service_handle;
408
409 /* Fill our internal UUID with a fixed pattern 0x82 */
410 std::array<uint8_t, Uuid::kNumBytes128> tmp;
411 tmp.fill(0x82);
412 Uuid app_uuid = Uuid::From128BitBE(tmp);
413 gatt_attr.fill({});
414
415 gatt_if = GATT_Register(app_uuid, "Gap", &gap_cback, false);
416
417 GATT_StartIf(gatt_if);
418
419 Uuid svc_uuid = Uuid::From16Bit(UUID_SERVCLASS_GAP_SERVER);
420 Uuid name_uuid = Uuid::From16Bit(GATT_UUID_GAP_DEVICE_NAME);
421 Uuid icon_uuid = Uuid::From16Bit(GATT_UUID_GAP_ICON);
422 Uuid addr_res_uuid = Uuid::From16Bit(GATT_UUID_GAP_CENTRAL_ADDR_RESOL);
423
424 btgatt_db_element_t service[] = {
425 {
426 .uuid = svc_uuid,
427 .type = BTGATT_DB_PRIMARY_SERVICE,
428 },
429 {.uuid = name_uuid,
430 .type = BTGATT_DB_CHARACTERISTIC,
431 .properties = GATT_CHAR_PROP_BIT_READ,
432 .permissions = GATT_PERM_READ},
433 {.uuid = icon_uuid,
434 .type = BTGATT_DB_CHARACTERISTIC,
435 .properties = GATT_CHAR_PROP_BIT_READ,
436 .permissions = GATT_PERM_READ},
437 {.uuid = addr_res_uuid,
438 .type = BTGATT_DB_CHARACTERISTIC,
439 .properties = GATT_CHAR_PROP_BIT_READ,
440 .permissions = GATT_PERM_READ}
441 #if (BTM_PERIPHERAL_ENABLED == TRUE) /* Only needed for peripheral testing */
442 ,
443 {.uuid = Uuid::From16Bit(GATT_UUID_GAP_PREF_CONN_PARAM),
444 .type = BTGATT_DB_CHARACTERISTIC,
445 .properties = GATT_CHAR_PROP_BIT_READ,
446 .permissions = GATT_PERM_READ}
447 #endif
448 };
449
450 /* Add a GAP service */
451 GATTS_AddService(gatt_if, service,
452 sizeof(service) / sizeof(btgatt_db_element_t));
453 service_handle = service[0].attribute_handle;
454
455 DVLOG(1) << __func__ << ": service_handle = " << +service_handle;
456
457 gatt_attr[0].uuid = GATT_UUID_GAP_DEVICE_NAME;
458 gatt_attr[0].handle = service[1].attribute_handle;
459
460 gatt_attr[1].uuid = GATT_UUID_GAP_ICON;
461 gatt_attr[1].handle = service[2].attribute_handle;
462
463 gatt_attr[2].uuid = GATT_UUID_GAP_CENTRAL_ADDR_RESOL;
464 gatt_attr[2].handle = service[3].attribute_handle;
465 gatt_attr[2].attr_value.addr_resolution = 0;
466
467 #if (BTM_PERIPHERAL_ENABLED == TRUE) /* Only needed for peripheral testing */
468
469 gatt_attr[3].uuid = GATT_UUID_GAP_PREF_CONN_PARAM;
470 gatt_attr[3].attr_value.conn_param.int_max = GAP_PREFER_CONN_INT_MAX; /* 6 */
471 gatt_attr[3].attr_value.conn_param.int_min = GAP_PREFER_CONN_INT_MIN; /* 0 */
472 gatt_attr[3].attr_value.conn_param.latency = GAP_PREFER_CONN_LATENCY; /* 0 */
473 gatt_attr[3].attr_value.conn_param.sp_tout =
474 GAP_PREFER_CONN_SP_TOUT; /* 2000 */
475 gatt_attr[3].handle = service[4].attribute_handle;
476 #endif
477 }
478
479 /*******************************************************************************
480 *
481 * Function GAP_BleAttrDBUpdate
482 *
483 * Description GAP ATT database update.
484 *
485 ******************************************************************************/
GAP_BleAttrDBUpdate(uint16_t attr_uuid,tGAP_BLE_ATTR_VALUE * p_value)486 void GAP_BleAttrDBUpdate(uint16_t attr_uuid, tGAP_BLE_ATTR_VALUE* p_value) {
487 DVLOG(1) << StringPrintf("%s: attr_uuid=0x%04x", __func__, attr_uuid);
488
489 for (tGAP_ATTR& db_attr : gatt_attr) {
490 if (db_attr.uuid == attr_uuid) {
491 DVLOG(1) << StringPrintf("Found attr_uuid=0x%04x", attr_uuid);
492
493 switch (attr_uuid) {
494 case GATT_UUID_GAP_ICON:
495 db_attr.attr_value.icon = p_value->icon;
496 break;
497
498 case GATT_UUID_GAP_PREF_CONN_PARAM:
499 memcpy((void*)&db_attr.attr_value.conn_param,
500 (const void*)&p_value->conn_param,
501 sizeof(tGAP_BLE_PREF_PARAM));
502 break;
503
504 case GATT_UUID_GAP_DEVICE_NAME:
505 BTM_SetLocalDeviceName((char*)p_value->p_dev_name);
506 break;
507
508 case GATT_UUID_GAP_CENTRAL_ADDR_RESOL:
509 db_attr.attr_value.addr_resolution = p_value->addr_resolution;
510 break;
511 }
512 break;
513 }
514 }
515
516 return;
517 }
518
519 /*******************************************************************************
520 *
521 * Function GAP_BleReadPeerPrefConnParams
522 *
523 * Description Start a process to read a connected peripheral's preferred
524 * connection parameters
525 *
526 * Returns true if read started, else false if GAP is busy
527 *
528 ******************************************************************************/
GAP_BleReadPeerPrefConnParams(const RawAddress & peer_bda)529 bool GAP_BleReadPeerPrefConnParams(const RawAddress& peer_bda) {
530 return accept_client_operation(peer_bda, GATT_UUID_GAP_PREF_CONN_PARAM, NULL);
531 }
532
533 /*******************************************************************************
534 *
535 * Function GAP_BleReadPeerDevName
536 *
537 * Description Start a process to read a connected peripheral's device
538 * name.
539 *
540 * Returns true if request accepted
541 *
542 ******************************************************************************/
GAP_BleReadPeerDevName(const RawAddress & peer_bda,tGAP_BLE_CMPL_CBACK * p_cback)543 bool GAP_BleReadPeerDevName(const RawAddress& peer_bda,
544 tGAP_BLE_CMPL_CBACK* p_cback) {
545 return accept_client_operation(peer_bda, GATT_UUID_GAP_DEVICE_NAME, p_cback);
546 }
547
548 /*******************************************************************************
549 *
550 * Function GAP_BleCancelReadPeerDevName
551 *
552 * Description Cancel reading a peripheral's device name.
553 *
554 * Returns true if request accepted
555 *
556 ******************************************************************************/
GAP_BleCancelReadPeerDevName(const RawAddress & peer_bda)557 bool GAP_BleCancelReadPeerDevName(const RawAddress& peer_bda) {
558 tGAP_CLCB* p_clcb = find_clcb_by_bd_addr(peer_bda);
559
560 DVLOG(1) << __func__ << ": BDA: " << peer_bda
561 << StringPrintf(" cl_op_uuid: 0x%04x",
562 (p_clcb == NULL) ? 0 : p_clcb->cl_op_uuid);
563
564 if (p_clcb == NULL) {
565 LOG(ERROR) << "Cannot cancel current op is not get dev name";
566 return false;
567 }
568
569 if (!p_clcb->connected) {
570 if (!GATT_CancelConnect(gatt_if, peer_bda, true)) {
571 LOG(ERROR) << "Cannot cancel where No connection id";
572 return false;
573 }
574 }
575
576 cl_op_cmpl(*p_clcb, false, 0, NULL);
577
578 return (true);
579 }
580