1 /******************************************************************************
3 * Copyright (C) 2010-2012 Broadcom Corporation
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 ******************************************************************************/
19 /******************************************************************************
21 * This is the implementation of the API for GATT module of BTA.
23 ******************************************************************************/
25 #include "bt_target.h"
27 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
30 #include "bt_common.h"
32 #include "bta_gatt_api.h"
33 #include "bta_gattc_int.h"
35 /*****************************************************************************
37 *****************************************************************************/
39 static const tBTA_SYS_REG bta_gattc_reg =
46 /*******************************************************************************
48 ** Function BTA_GATTC_Disable
50 ** Description This function is called to disable GATTC module
56 *******************************************************************************/
57 void BTA_GATTC_Disable(void)
59 if (bta_sys_is_register(BTA_ID_GATTC) == FALSE)
61 APPL_TRACE_WARNING("GATTC Module not enabled/already disabled");
65 BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR));
66 p_buf->event = BTA_GATTC_API_DISABLE_EVT;
68 bta_sys_sendmsg(p_buf);
69 bta_sys_deregister(BTA_ID_GATTC);
72 /*******************************************************************************
74 ** Function BTA_GATTC_AppRegister
76 ** Description This function is called to register application callbacks
77 ** with BTA GATTC module.
79 ** Parameters p_app_uuid - applicaiton UUID
80 ** p_client_cb - pointer to the application callback function.
84 *******************************************************************************/
85 void BTA_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb)
87 tBTA_GATTC_API_REG *p_buf =
88 (tBTA_GATTC_API_REG *)osi_malloc(sizeof(tBTA_GATTC_API_REG));
90 if (bta_sys_is_register(BTA_ID_GATTC) == FALSE)
91 bta_sys_register(BTA_ID_GATTC, &bta_gattc_reg);
93 p_buf->hdr.event = BTA_GATTC_API_REG_EVT;
94 if (p_app_uuid != NULL)
95 memcpy(&p_buf->app_uuid, p_app_uuid, sizeof(tBT_UUID));
96 p_buf->p_cback = p_client_cb;
98 bta_sys_sendmsg(p_buf);
101 /*******************************************************************************
103 ** Function BTA_GATTC_AppDeregister
105 ** Description This function is called to deregister an application
106 ** from BTA GATTC module.
108 ** Parameters client_if - client interface identifier.
112 *******************************************************************************/
113 void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if)
115 tBTA_GATTC_API_DEREG *p_buf =
116 (tBTA_GATTC_API_DEREG *)osi_malloc(sizeof(tBTA_GATTC_API_DEREG));
118 p_buf->hdr.event = BTA_GATTC_API_DEREG_EVT;
119 p_buf->client_if = client_if;
121 bta_sys_sendmsg(p_buf);
124 /*******************************************************************************
126 ** Function BTA_GATTC_Open
128 ** Description Open a direct connection or add a background auto connection
131 ** Parameters client_if: server interface.
132 ** remote_bda: remote device BD address.
133 ** is_direct: direct connection or background auto connection
134 ** transport: Transport to be used for GATT connection (BREDR/LE)
138 *******************************************************************************/
139 void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
140 BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport)
142 tBTA_GATTC_API_OPEN *p_buf =
143 (tBTA_GATTC_API_OPEN *) osi_malloc(sizeof(tBTA_GATTC_API_OPEN));
145 p_buf->hdr.event = BTA_GATTC_API_OPEN_EVT;
146 p_buf->client_if = client_if;
147 p_buf->is_direct = is_direct;
148 p_buf->transport = transport;
149 memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);
151 bta_sys_sendmsg(p_buf);
154 /*******************************************************************************
156 ** Function BTA_GATTC_CancelOpen
158 ** Description Cancel a direct open connection or remove a background auto connection
161 ** Parameters client_if: server interface.
162 ** remote_bda: remote device BD address.
163 ** is_direct: direct connection or background auto connection
167 *******************************************************************************/
168 void BTA_GATTC_CancelOpen(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN is_direct)
170 tBTA_GATTC_API_CANCEL_OPEN *p_buf =
171 (tBTA_GATTC_API_CANCEL_OPEN *)osi_malloc(sizeof(tBTA_GATTC_API_CANCEL_OPEN));
173 p_buf->hdr.event = BTA_GATTC_API_CANCEL_OPEN_EVT;
174 p_buf->client_if = client_if;
175 p_buf->is_direct = is_direct;
176 memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);
178 bta_sys_sendmsg(p_buf);
181 /*******************************************************************************
183 ** Function BTA_GATTC_Close
185 ** Description Close a connection to a GATT server.
187 ** Parameters conn_id: connectino ID to be closed.
191 *******************************************************************************/
192 void BTA_GATTC_Close(UINT16 conn_id)
194 BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR));
196 p_buf->event = BTA_GATTC_API_CLOSE_EVT;
197 p_buf->layer_specific = conn_id;
199 bta_sys_sendmsg(p_buf);
202 /*******************************************************************************
204 ** Function BTA_GATTC_ConfigureMTU
206 ** Description Configure the MTU size in the GATT channel. This can be done
207 ** only once per connection.
209 ** Parameters conn_id: connection ID.
210 ** mtu: desired MTU size to use.
214 *******************************************************************************/
215 void BTA_GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu)
217 tBTA_GATTC_API_CFG_MTU *p_buf =
218 (tBTA_GATTC_API_CFG_MTU *)osi_malloc(sizeof(tBTA_GATTC_API_CFG_MTU));
220 p_buf->hdr.event = BTA_GATTC_API_CFG_MTU_EVT;
221 p_buf->hdr.layer_specific = conn_id;
224 bta_sys_sendmsg(p_buf);
227 /*******************************************************************************
229 ** Function BTA_GATTC_ServiceSearchRequest
231 ** Description This function is called to request a GATT service discovery
232 ** on a GATT server. This function report service search result
233 ** by a callback event, and followed by a service search complete
236 ** Parameters conn_id: connection ID.
237 ** p_srvc_uuid: a UUID of the service application is interested in.
238 ** If Null, discover for all services.
242 *******************************************************************************/
243 void BTA_GATTC_ServiceSearchRequest (UINT16 conn_id, tBT_UUID *p_srvc_uuid)
245 const size_t len = sizeof(tBTA_GATTC_API_SEARCH) + sizeof(tBT_UUID);
246 tBTA_GATTC_API_SEARCH *p_buf = (tBTA_GATTC_API_SEARCH *)osi_calloc(len);
248 p_buf->hdr.event = BTA_GATTC_API_SEARCH_EVT;
249 p_buf->hdr.layer_specific = conn_id;
251 p_buf->p_srvc_uuid = (tBT_UUID *)(p_buf + 1);
252 memcpy(p_buf->p_srvc_uuid, p_srvc_uuid, sizeof(tBT_UUID));
254 p_buf->p_srvc_uuid = NULL;
257 bta_sys_sendmsg(p_buf);
260 /*******************************************************************************
262 ** Function BTA_GATTC_GetServices
264 ** Description This function is called to find the services on the given server.
266 ** Parameters conn_id: connection ID which identify the server.
268 ** Returns returns list_t of tBTA_GATTC_SERVICE or NULL.
270 *******************************************************************************/
271 const list_t* BTA_GATTC_GetServices(UINT16 conn_id) {
272 return bta_gattc_get_services(conn_id);
275 /*******************************************************************************
277 ** Function BTA_GATTC_GetCharacteristic
279 ** Description This function is called to find the characteristic on the given server.
281 ** Parameters conn_id - connection ID which identify the server.
282 ** handle - characteristic handle
284 ** Returns returns pointer to tBTA_GATTC_CHARACTERISTIC or NULL.
286 *******************************************************************************/
287 const tBTA_GATTC_CHARACTERISTIC* BTA_GATTC_GetCharacteristic(UINT16 conn_id, UINT16 handle) {
288 return bta_gattc_get_characteristic(conn_id, handle);
291 /*******************************************************************************
293 ** Function BTA_GATTC_GetDescriptor
295 ** Description This function is called to find the characteristic on the given server.
297 ** Parameters conn_id - connection ID which identify the server.
298 ** handle - descriptor handle
300 ** Returns returns pointer to tBTA_GATTC_DESCRIPTOR or NULL.
302 *******************************************************************************/
303 const tBTA_GATTC_DESCRIPTOR* BTA_GATTC_GetDescriptor(UINT16 conn_id, UINT16 handle) {
304 return bta_gattc_get_descriptor(conn_id, handle);
307 /*******************************************************************************
309 ** Function BTA_GATTC_GetGattDb
311 ** Description This function is called to get the GATT database.
313 ** Parameters conn_id: connection ID which identify the server.
314 ** db: output parameter which will contain the GATT database copy.
315 ** Caller is responsible for freeing it.
316 ** count: number of elements in database.
318 *******************************************************************************/
319 void BTA_GATTC_GetGattDb(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle,
320 btgatt_db_element_t **db, int *count)
322 bta_gattc_get_gatt_db(conn_id, start_handle, end_handle, db, count);
325 /*******************************************************************************
327 ** Function BTA_GATTC_ReadCharacteristic
329 ** Description This function is called to read a characteristics value
331 ** Parameters conn_id - connection ID.
332 ** handle - characteritic handle to read.
336 *******************************************************************************/
337 void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, UINT16 handle, tBTA_GATT_AUTH_REQ auth_req)
339 tBTA_GATTC_API_READ *p_buf =
340 (tBTA_GATTC_API_READ *)osi_calloc(sizeof(tBTA_GATTC_API_READ));
342 p_buf->hdr.event = BTA_GATTC_API_READ_EVT;
343 p_buf->hdr.layer_specific = conn_id;
344 p_buf->auth_req = auth_req;
345 p_buf->handle = handle;
346 p_buf->cmpl_evt = BTA_GATTC_READ_CHAR_EVT;
348 bta_sys_sendmsg(p_buf);
351 /*******************************************************************************
353 ** Function BTA_GATTC_ReadCharDescr
355 ** Description This function is called to read a descriptor value.
357 ** Parameters conn_id - connection ID.
358 ** handle - descriptor handle to read.
362 *******************************************************************************/
363 void BTA_GATTC_ReadCharDescr (UINT16 conn_id, UINT16 handle, tBTA_GATT_AUTH_REQ auth_req)
365 tBTA_GATTC_API_READ *p_buf =
366 (tBTA_GATTC_API_READ *)osi_calloc(sizeof(tBTA_GATTC_API_READ));
368 p_buf->hdr.event = BTA_GATTC_API_READ_EVT;
369 p_buf->hdr.layer_specific = conn_id;
370 p_buf->auth_req = auth_req;
371 p_buf->handle = handle;
372 p_buf->cmpl_evt = BTA_GATTC_READ_DESCR_EVT;
374 bta_sys_sendmsg(p_buf);
377 /*******************************************************************************
379 ** Function BTA_GATTC_ReadMultiple
381 ** Description This function is called to read multiple characteristic or
382 ** characteristic descriptors.
384 ** Parameters conn_id - connectino ID.
385 ** p_read_multi - pointer to the read multiple parameter.
389 *******************************************************************************/
390 void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
391 tBTA_GATT_AUTH_REQ auth_req)
393 tBTA_GATTC_API_READ_MULTI *p_buf =
394 (tBTA_GATTC_API_READ_MULTI *)osi_calloc(sizeof(tBTA_GATTC_API_READ_MULTI));
396 p_buf->hdr.event = BTA_GATTC_API_READ_MULTI_EVT;
397 p_buf->hdr.layer_specific = conn_id;
398 p_buf->auth_req = auth_req;
399 p_buf->num_attr = p_read_multi->num_attr;
401 if (p_buf->num_attr > 0)
402 memcpy(p_buf->handles, p_read_multi->handles, sizeof(UINT16) * p_read_multi->num_attr);
404 bta_sys_sendmsg(p_buf);
407 /*******************************************************************************
409 ** Function BTA_GATTC_WriteCharValue
411 ** Description This function is called to write characteristic value.
413 ** Parameters conn_id - connection ID.
414 ** handle - characteristic handle to write.
415 ** write_type - type of write.
416 ** len: length of the data to be written.
417 ** p_value - the value to be written.
421 *******************************************************************************/
422 void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
424 tBTA_GATTC_WRITE_TYPE write_type,
427 tBTA_GATT_AUTH_REQ auth_req)
429 tBTA_GATTC_API_WRITE *p_buf =
430 (tBTA_GATTC_API_WRITE *)osi_calloc(sizeof(tBTA_GATTC_API_WRITE) + len);
432 p_buf->hdr.event = BTA_GATTC_API_WRITE_EVT;
433 p_buf->hdr.layer_specific = conn_id;
434 p_buf->auth_req = auth_req;
435 p_buf->handle = handle;
436 p_buf->cmpl_evt = BTA_GATTC_WRITE_CHAR_EVT;
437 p_buf->write_type = write_type;
440 if (p_value && len > 0) {
441 p_buf->p_value = (UINT8 *)(p_buf + 1);
442 memcpy(p_buf->p_value, p_value, len);
445 bta_sys_sendmsg(p_buf);
448 /*******************************************************************************
450 ** Function BTA_GATTC_WriteCharDescr
452 ** Description This function is called to write descriptor value.
454 ** Parameters conn_id - connection ID
455 ** handle - descriptor hadle to write.
456 ** write_type - write type.
457 ** p_value - the value to be written.
461 *******************************************************************************/
462 void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
464 tBTA_GATTC_WRITE_TYPE write_type,
465 tBTA_GATT_UNFMT *p_data,
466 tBTA_GATT_AUTH_REQ auth_req)
468 size_t len = sizeof(tBTA_GATTC_API_WRITE);
473 tBTA_GATTC_API_WRITE *p_buf = (tBTA_GATTC_API_WRITE *)osi_calloc(len);
474 p_buf->hdr.event = BTA_GATTC_API_WRITE_EVT;
475 p_buf->hdr.layer_specific = conn_id;
476 p_buf->auth_req = auth_req;
477 p_buf->handle = handle;
478 p_buf->cmpl_evt = BTA_GATTC_WRITE_DESCR_EVT;
479 p_buf->write_type = write_type;
481 if (p_data && p_data->len != 0) {
482 p_buf->p_value = (UINT8 *)(p_buf + 1);
483 p_buf->len = p_data->len;
484 /* pack the descr data */
485 memcpy(p_buf->p_value, p_data->p_value, p_data->len);
488 bta_sys_sendmsg(p_buf);
491 /*******************************************************************************
493 ** Function BTA_GATTC_PrepareWrite
495 ** Description This function is called to prepare write a characteristic value.
497 ** Parameters conn_id - connection ID.
498 ** p_char_id - GATT characteritic ID of the service.
499 ** offset - offset of the write value.
500 ** len: length of the data to be written.
501 ** p_value - the value to be written.
505 *******************************************************************************/
506 void BTA_GATTC_PrepareWrite (UINT16 conn_id, UINT16 handle,
507 UINT16 offset, UINT16 len, UINT8 *p_value,
508 tBTA_GATT_AUTH_REQ auth_req)
510 tBTA_GATTC_API_WRITE *p_buf =
511 (tBTA_GATTC_API_WRITE *)osi_calloc(sizeof(tBTA_GATTC_API_WRITE) + len);
513 p_buf->hdr.event = BTA_GATTC_API_WRITE_EVT;
514 p_buf->hdr.layer_specific = conn_id;
515 p_buf->auth_req = auth_req;
516 p_buf->handle = handle;
518 p_buf->write_type = BTA_GATTC_WRITE_PREPARE;
519 p_buf->offset = offset;
522 if (p_value && len > 0) {
523 p_buf->p_value = (UINT8 *)(p_buf + 1);
524 memcpy(p_buf->p_value, p_value, len);
527 bta_sys_sendmsg(p_buf);
530 /*******************************************************************************
532 ** Function BTA_GATTC_ExecuteWrite
534 ** Description This function is called to execute write a prepare write sequence.
536 ** Parameters conn_id - connection ID.
537 ** is_execute - execute or cancel.
541 *******************************************************************************/
542 void BTA_GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute)
544 tBTA_GATTC_API_EXEC *p_buf =
545 (tBTA_GATTC_API_EXEC *)osi_calloc(sizeof(tBTA_GATTC_API_EXEC));
547 p_buf->hdr.event = BTA_GATTC_API_EXEC_EVT;
548 p_buf->hdr.layer_specific = conn_id;
549 p_buf->is_execute = is_execute;
551 bta_sys_sendmsg(p_buf);
554 /*******************************************************************************
556 ** Function BTA_GATTC_SendIndConfirm
558 ** Description This function is called to send handle value confirmation.
560 ** Parameters conn_id - connection ID.
561 ** p_char_id - characteristic ID to confirm.
565 *******************************************************************************/
566 void BTA_GATTC_SendIndConfirm (UINT16 conn_id, UINT16 handle)
568 tBTA_GATTC_API_CONFIRM *p_buf =
569 (tBTA_GATTC_API_CONFIRM *)osi_calloc(sizeof(tBTA_GATTC_API_CONFIRM));
571 APPL_TRACE_API("%s conn_id=%d handle=0x%04x", __func__, conn_id, handle);
573 p_buf->hdr.event = BTA_GATTC_API_CONFIRM_EVT;
574 p_buf->hdr.layer_specific = conn_id;
575 p_buf->handle = handle;
577 bta_sys_sendmsg(p_buf);
580 /*******************************************************************************
582 ** Function BTA_GATTC_RegisterForNotifications
584 ** Description This function is called to register for notification of a service.
586 ** Parameters client_if - client interface.
587 ** bda - target GATT server.
588 ** handle - GATT characteristic handle.
590 ** Returns OK if registration succeed, otherwise failed.
592 *******************************************************************************/
593 tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
594 BD_ADDR bda, UINT16 handle)
596 tBTA_GATTC_RCB *p_clreg;
597 tBTA_GATT_STATUS status = BTA_GATT_ILLEGAL_PARAMETER;
602 APPL_TRACE_ERROR("deregistration failed, handle is 0");
606 if ((p_clreg = bta_gattc_cl_get_regcb(client_if)) != NULL)
608 for (i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i ++)
610 if ( p_clreg->notif_reg[i].in_use &&
611 !memcmp(p_clreg->notif_reg[i].remote_bda, bda, BD_ADDR_LEN) &&
612 p_clreg->notif_reg[i].handle == handle)
614 APPL_TRACE_WARNING("notification already registered");
615 status = BTA_GATT_OK;
619 if (status != BTA_GATT_OK)
621 for (i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i ++)
623 if (!p_clreg->notif_reg[i].in_use)
625 memset((void *)&p_clreg->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
627 p_clreg->notif_reg[i].in_use = TRUE;
628 memcpy(p_clreg->notif_reg[i].remote_bda, bda, BD_ADDR_LEN);
630 p_clreg->notif_reg[i].handle = handle;
631 status = BTA_GATT_OK;
635 if (i == BTA_GATTC_NOTIF_REG_MAX)
637 status = BTA_GATT_NO_RESOURCES;
638 APPL_TRACE_ERROR("Max Notification Reached, registration failed.");
644 APPL_TRACE_ERROR("Client_if: %d Not Registered", client_if);
650 /*******************************************************************************
652 ** Function BTA_GATTC_DeregisterForNotifications
654 ** Description This function is called to de-register for notification of a servbice.
656 ** Parameters client_if - client interface.
657 ** remote_bda - target GATT server.
658 ** handle - GATT characteristic handle.
660 ** Returns OK if deregistration succeed, otherwise failed.
662 *******************************************************************************/
663 tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if,
664 BD_ADDR bda, UINT16 handle)
667 APPL_TRACE_ERROR("%s: deregistration failed, handle is 0", __func__);
668 return BTA_GATT_ILLEGAL_PARAMETER;
671 tBTA_GATTC_RCB *p_clreg = bta_gattc_cl_get_regcb(client_if);
672 if (p_clreg == NULL) {
673 APPL_TRACE_ERROR("%s client_if: %d not registered bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
674 __func__, client_if, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
675 return BTA_GATT_ILLEGAL_PARAMETER;
678 for (int i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i ++) {
679 if (p_clreg->notif_reg[i].in_use &&
680 !memcmp(p_clreg->notif_reg[i].remote_bda, bda, BD_ADDR_LEN) &&
681 p_clreg->notif_reg[i].handle == handle) {
682 APPL_TRACE_DEBUG("%s deregistered bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
683 __func__, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
684 memset(&p_clreg->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
689 APPL_TRACE_ERROR("%s registration not found bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
690 __func__, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
691 return BTA_GATT_ERROR;
694 /*******************************************************************************
696 ** Function BTA_GATTC_Refresh
698 ** Description Refresh the server cache of the remote device
700 ** Parameters remote_bda: remote device BD address.
704 *******************************************************************************/
705 void BTA_GATTC_Refresh(BD_ADDR remote_bda)
707 tBTA_GATTC_API_OPEN *p_buf =
708 (tBTA_GATTC_API_OPEN *)osi_malloc(sizeof(tBTA_GATTC_API_OPEN));
710 p_buf->hdr.event = BTA_GATTC_API_REFRESH_EVT;
711 memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);
713 bta_sys_sendmsg(p_buf);
716 /*******************************************************************************
718 ** Function BTA_GATTC_Listen
720 ** Description Start advertisement to listen for connection request for a GATT
721 ** client application.
723 ** Parameters client_if: server interface.
724 ** start: to start or stop listening for connection
725 ** remote_bda: remote device BD address, if listen to all device
730 *******************************************************************************/
731 void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, BOOLEAN start, BD_ADDR_PTR target_bda)
733 tBTA_GATTC_API_LISTEN *p_buf =
734 (tBTA_GATTC_API_LISTEN *)osi_malloc(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN);
736 p_buf->hdr.event = BTA_GATTC_API_LISTEN_EVT;
737 p_buf->client_if = client_if;
738 p_buf->start = start;
740 p_buf->remote_bda = (UINT8*)(p_buf + 1);
741 memcpy(p_buf->remote_bda, target_bda, BD_ADDR_LEN);
743 p_buf->remote_bda = NULL;
746 bta_sys_sendmsg(p_buf);
749 /*******************************************************************************
751 ** Function BTA_GATTC_Broadcast
753 ** Description Start broadcasting (non-connectable advertisements)
755 ** Parameters client_if: client interface.
756 ** start: to start or stop listening for connection
760 *******************************************************************************/
761 void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start)
763 tBTA_GATTC_API_LISTEN *p_buf =
764 (tBTA_GATTC_API_LISTEN *)osi_malloc(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN);
766 p_buf->hdr.event = BTA_GATTC_API_BROADCAST_EVT;
767 p_buf->client_if = client_if;
768 p_buf->start = start;
770 bta_sys_sendmsg(p_buf);
773 #endif /* BTA_GATT_INCLUDED */