1 /******************************************************************************
3 * Copyright (C) 2003-2014 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 API implementation file for the BTA device manager.
23 ******************************************************************************/
28 #include "bta_dm_int.h"
29 #include "bta_sys_int.h"
35 /*****************************************************************************
37 *****************************************************************************/
39 static const tBTA_SYS_REG bta_dm_reg =
45 static const tBTA_SYS_REG bta_dm_search_reg =
47 bta_dm_search_sm_execute,
48 bta_dm_search_sm_disable
51 /*******************************************************************************
53 ** Function BTA_EnableBluetooth
55 ** Description Enables bluetooth service. This function must be
56 ** called before any other functions in the BTA API are called.
59 ** Returns tBTA_STATUS
61 *******************************************************************************/
62 tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK *p_cback)
65 tBTA_DM_API_ENABLE *p_msg;
67 /* Bluetooth disabling is in progress */
68 if (bta_dm_cb.disabling)
71 memset(&bta_dm_cb, 0, sizeof(bta_dm_cb));
73 bta_sys_register (BTA_ID_DM, &bta_dm_reg );
74 bta_sys_register (BTA_ID_DM_SEARCH, &bta_dm_search_reg );
76 /* if UUID list is not provided as static data */
77 bta_sys_eir_register(bta_dm_eir_update_uuid);
79 if ((p_msg = (tBTA_DM_API_ENABLE *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE))) != NULL)
81 p_msg->hdr.event = BTA_DM_API_ENABLE_EVT;
82 p_msg->p_sec_cback = p_cback;
83 bta_sys_sendmsg(p_msg);
90 /*******************************************************************************
92 ** Function BTA_DisableBluetooth
94 ** Description Disables bluetooth service. This function is called when
95 ** the application no longer needs bluetooth service
99 *******************************************************************************/
100 tBTA_STATUS BTA_DisableBluetooth(void)
105 if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
107 p_msg->event = BTA_DM_API_DISABLE_EVT;
108 bta_sys_sendmsg(p_msg);
118 /*******************************************************************************
120 ** Function BTA_EnableTestMode
122 ** Description Enables bluetooth device under test mode
125 ** Returns tBTA_STATUS
127 *******************************************************************************/
128 tBTA_STATUS BTA_EnableTestMode(void)
132 APPL_TRACE_API("BTA_EnableTestMode");
134 if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
136 p_msg->event = BTA_DM_API_ENABLE_TEST_MODE_EVT;
137 bta_sys_sendmsg(p_msg);
143 /*******************************************************************************
145 ** Function BTA_DisableTestMode
147 ** Description Disable bluetooth device under test mode
152 *******************************************************************************/
153 void BTA_DisableTestMode(void)
157 APPL_TRACE_API("BTA_DisableTestMode");
159 if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
161 p_msg->event = BTA_DM_API_DISABLE_TEST_MODE_EVT;
162 bta_sys_sendmsg(p_msg);
166 /*******************************************************************************
168 ** Function BTA_DmSetDeviceName
170 ** Description This function sets the Bluetooth name of local device
175 *******************************************************************************/
176 void BTA_DmSetDeviceName(char *p_name)
179 tBTA_DM_API_SET_NAME *p_msg;
181 if ((p_msg = (tBTA_DM_API_SET_NAME *) GKI_getbuf(sizeof(tBTA_DM_API_SET_NAME))) != NULL)
183 p_msg->hdr.event = BTA_DM_API_SET_NAME_EVT;
184 /* truncate the name if needed */
185 BCM_STRNCPY_S((char*)p_msg->name, sizeof(p_msg->name), p_name, BD_NAME_LEN-1);
186 p_msg->name[BD_NAME_LEN-1]=0;
188 bta_sys_sendmsg(p_msg);
194 /*******************************************************************************
196 ** Function BTA_DmSetVisibility
198 ** Description This function sets the Bluetooth connectable,
199 ** discoverable, pairable and conn paired only modes of local device
204 *******************************************************************************/
205 void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode, UINT8 pairable_mode, UINT8 conn_filter )
208 tBTA_DM_API_SET_VISIBILITY *p_msg;
210 if ((p_msg = (tBTA_DM_API_SET_VISIBILITY *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
212 p_msg->hdr.event = BTA_DM_API_SET_VISIBILITY_EVT;
213 p_msg->disc_mode = disc_mode;
214 p_msg->conn_mode = conn_mode;
215 p_msg->pair_mode = pairable_mode;
216 p_msg->conn_paired_only = conn_filter;
219 bta_sys_sendmsg(p_msg);
225 /*******************************************************************************
227 ** Function BTA_DmSearch
229 ** Description This function searches for peer Bluetooth devices. It performs
230 ** an inquiry and gets the remote name for devices. Service
231 ** discovery is done if services is non zero
236 *******************************************************************************/
237 void BTA_DmSearch(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK services, tBTA_DM_SEARCH_CBACK *p_cback)
240 tBTA_DM_API_SEARCH *p_msg;
242 if ((p_msg = (tBTA_DM_API_SEARCH *) GKI_getbuf(sizeof(tBTA_DM_API_SEARCH))) != NULL)
244 memset(p_msg, 0, sizeof(tBTA_DM_API_SEARCH));
246 p_msg->hdr.event = BTA_DM_API_SEARCH_EVT;
247 memcpy(&p_msg->inq_params, p_dm_inq, sizeof(tBTA_DM_INQ));
248 p_msg->services = services;
249 p_msg->p_cback = p_cback;
250 p_msg->rs_res = BTA_DM_RS_NONE;
251 bta_sys_sendmsg(p_msg);
257 /*******************************************************************************
259 ** Function BTA_DmSearchCancel
261 ** Description This function cancels a search initiated by BTA_DmSearch
266 *******************************************************************************/
267 void BTA_DmSearchCancel(void)
271 if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
273 p_msg->event = BTA_DM_API_SEARCH_CANCEL_EVT;
274 bta_sys_sendmsg(p_msg);
279 /*******************************************************************************
281 ** Function BTA_DmDiscover
283 ** Description This function does service discovery for services of a
289 *******************************************************************************/
290 void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
291 tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search)
293 tBTA_DM_API_DISCOVER *p_msg;
295 if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL)
297 memset(p_msg, 0, sizeof(tBTA_DM_API_DISCOVER));
299 p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
300 bdcpy(p_msg->bd_addr, bd_addr);
301 p_msg->services = services;
302 p_msg->p_cback = p_cback;
303 p_msg->sdp_search = sdp_search;
304 bta_sys_sendmsg(p_msg);
309 /*******************************************************************************
311 ** Function BTA_DmDiscoverUUID
313 ** Description This function does service discovery for services of a
319 *******************************************************************************/
320 void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
321 tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search)
323 tBTA_DM_API_DISCOVER *p_msg;
325 if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL)
327 p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
328 bdcpy(p_msg->bd_addr, bd_addr);
329 p_msg->services = BTA_USER_SERVICE_MASK; //Not exposed at API level
330 p_msg->p_cback = p_cback;
331 p_msg->sdp_search = sdp_search;
333 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
335 p_msg->p_uuid = NULL;
337 memcpy( &p_msg->uuid, uuid, sizeof(tSDP_UUID) );
338 bta_sys_sendmsg(p_msg);
343 /*******************************************************************************
345 ** Function BTA_DmBond
347 ** Description This function initiates a bonding procedure with a peer
353 *******************************************************************************/
354 void BTA_DmBond(BD_ADDR bd_addr)
356 tBTA_DM_API_BOND *p_msg;
358 p_msg = (tBTA_DM_API_BOND *) GKI_getbuf(sizeof(tBTA_DM_API_BOND));
361 p_msg->hdr.event = BTA_DM_API_BOND_EVT;
362 bdcpy(p_msg->bd_addr, bd_addr);
363 p_msg->transport = BTA_TRANSPORT_UNKNOWN;
364 bta_sys_sendmsg(p_msg);
368 /*******************************************************************************
370 ** Function BTA_DmBondByTransports
372 ** Description This function initiates a bonding procedure with a peer
378 *******************************************************************************/
379 void BTA_DmBondByTransport(BD_ADDR bd_addr, tBTA_TRANSPORT transport)
381 tBTA_DM_API_BOND *p_msg;
383 if ((p_msg = (tBTA_DM_API_BOND *) GKI_getbuf(sizeof(tBTA_DM_API_BOND))) != NULL)
385 p_msg->hdr.event = BTA_DM_API_BOND_EVT;
386 bdcpy(p_msg->bd_addr, bd_addr);
387 p_msg->transport = transport;
388 bta_sys_sendmsg(p_msg);
394 /*******************************************************************************
396 ** Function BTA_DmBondCancel
398 ** Description This function cancels the bonding procedure with a peer
404 *******************************************************************************/
405 void BTA_DmBondCancel(BD_ADDR bd_addr)
407 tBTA_DM_API_BOND_CANCEL *p_msg;
409 if ((p_msg = (tBTA_DM_API_BOND_CANCEL *) GKI_getbuf(sizeof(tBTA_DM_API_BOND_CANCEL))) != NULL)
411 p_msg->hdr.event = BTA_DM_API_BOND_CANCEL_EVT;
412 bdcpy(p_msg->bd_addr, bd_addr);
413 bta_sys_sendmsg(p_msg);
419 /*******************************************************************************
421 ** Function BTA_DmPinReply
423 ** Description This function provides a pincode for a remote device when
424 ** one is requested by DM through BTA_DM_PIN_REQ_EVT
429 *******************************************************************************/
430 void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len, UINT8 *p_pin)
433 tBTA_DM_API_PIN_REPLY *p_msg;
435 if ((p_msg = (tBTA_DM_API_PIN_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PIN_REPLY))) != NULL)
437 p_msg->hdr.event = BTA_DM_API_PIN_REPLY_EVT;
438 bdcpy(p_msg->bd_addr, bd_addr);
439 p_msg->accept = accept;
442 p_msg->pin_len = pin_len;
443 memcpy(p_msg->p_pin, p_pin, pin_len);
445 bta_sys_sendmsg(p_msg);
450 #if (BTM_OOB_INCLUDED == TRUE)
451 /*******************************************************************************
453 ** Function BTA_DmLocalOob
455 ** Description This function retrieves the OOB data from local controller.
456 ** The result is reported by:
457 ** - bta_dm_co_loc_oob_ext() if device supports secure
459 ** - bta_dm_co_loc_oob() if device doesn't support SC
463 *******************************************************************************/
464 void BTA_DmLocalOob(void)
466 tBTA_DM_API_LOC_OOB *p_msg;
468 if ((p_msg = (tBTA_DM_API_LOC_OOB *) GKI_getbuf(sizeof(tBTA_DM_API_LOC_OOB))) != NULL)
470 p_msg->hdr.event = BTA_DM_API_LOC_OOB_EVT;
471 bta_sys_sendmsg(p_msg);
474 #endif /* BTM_OOB_INCLUDED */
475 /*******************************************************************************
477 ** Function BTA_DmConfirm
479 ** Description This function accepts or rejects the numerical value of the
480 ** Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT
484 *******************************************************************************/
485 void BTA_DmConfirm(BD_ADDR bd_addr, BOOLEAN accept)
487 tBTA_DM_API_CONFIRM *p_msg;
489 if ((p_msg = (tBTA_DM_API_CONFIRM *) GKI_getbuf(sizeof(tBTA_DM_API_CONFIRM))) != NULL)
491 p_msg->hdr.event = BTA_DM_API_CONFIRM_EVT;
492 bdcpy(p_msg->bd_addr, bd_addr);
493 p_msg->accept = accept;
494 bta_sys_sendmsg(p_msg);
498 /*******************************************************************************
500 ** Function BTA_DmAddDevice
502 ** Description This function adds a device to the security database list of
508 *******************************************************************************/
509 void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key,
510 tBTA_SERVICE_MASK trusted_mask, BOOLEAN is_trusted,
511 UINT8 key_type, tBTA_IO_CAP io_cap, UINT8 pin_length)
514 tBTA_DM_API_ADD_DEVICE *p_msg;
516 if ((p_msg = (tBTA_DM_API_ADD_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_DEVICE))) != NULL)
518 memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_DEVICE));
520 p_msg->hdr.event = BTA_DM_API_ADD_DEVICE_EVT;
521 bdcpy(p_msg->bd_addr, bd_addr);
522 p_msg->tm = trusted_mask;
523 p_msg->is_trusted = is_trusted;
524 p_msg->io_cap = io_cap;
528 p_msg->link_key_known = TRUE;
529 p_msg->key_type = key_type;
530 memcpy(p_msg->link_key, link_key, LINK_KEY_LEN);
533 /* Load device class if specified */
536 p_msg->dc_known = TRUE;
537 memcpy (p_msg->dc, dev_class, DEV_CLASS_LEN);
540 memset (p_msg->bd_name, 0, BD_NAME_LEN + 1);
541 memset (p_msg->features, 0, sizeof (p_msg->features));
542 p_msg->pin_length = pin_length;
544 bta_sys_sendmsg(p_msg);
549 /*******************************************************************************
551 ** Function BTA_DmRemoveDevice
553 ** Description This function removes a device fromthe security database list of
554 ** peer device. It manages unpairing even while connected.
559 *******************************************************************************/
560 tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr)
562 tBTA_DM_API_REMOVE_DEVICE *p_msg;
564 if ((p_msg = (tBTA_DM_API_REMOVE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_REMOVE_DEVICE))) != NULL)
566 memset (p_msg, 0, sizeof(tBTA_DM_API_REMOVE_DEVICE));
568 p_msg->hdr.event = BTA_DM_API_REMOVE_DEVICE_EVT;
569 bdcpy(p_msg->bd_addr, bd_addr);
570 bta_sys_sendmsg(p_msg);
580 /*******************************************************************************
582 ** Function BTA_GetEirService
584 ** Description This function is called to get BTA service mask from EIR.
586 ** Parameters p_eir - pointer of EIR significant part
587 ** p_services - return the BTA service mask
591 *******************************************************************************/
592 extern const UINT16 bta_service_id_to_uuid_lkup_tbl [];
593 void BTA_GetEirService( UINT8 *p_eir, tBTA_SERVICE_MASK *p_services )
596 UINT8 num_uuid, max_num_uuid = 32;
597 UINT8 uuid_list[32*LEN_UUID_16];
598 UINT16 *p_uuid16 = (UINT16 *)uuid_list;
599 tBTA_SERVICE_MASK mask;
601 BTM_GetEirUuidList( p_eir, LEN_UUID_16, &num_uuid, uuid_list, max_num_uuid);
602 for( xx = 0; xx < num_uuid; xx++ )
605 for( yy = 0; yy < BTA_MAX_SERVICE_ID; yy++ )
607 if( *(p_uuid16 + xx) == bta_service_id_to_uuid_lkup_tbl[yy] )
615 /* for HSP v1.2 only device */
616 if (*(p_uuid16 + xx) == UUID_SERVCLASS_HEADSET_HS)
617 *p_services |= BTA_HSP_SERVICE_MASK;
619 if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SOURCE)
620 *p_services |= BTA_HL_SERVICE_MASK;
622 if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SINK)
623 *p_services |= BTA_HL_SERVICE_MASK;
627 /*******************************************************************************
629 ** Function BTA_DmGetConnectionState
631 ** Description Returns whether the remote device is currently connected.
633 ** Returns 0 if the device is NOT connected.
635 *******************************************************************************/
636 UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr )
638 tBTA_DM_PEER_DEVICE * p_dev = bta_dm_find_peer_device(bd_addr);
639 return (p_dev && p_dev->conn_state == BTA_DM_CONNECTED);
643 /*******************************************************************************
644 ** Device Identification (DI) Server Functions
645 *******************************************************************************/
646 /*******************************************************************************
648 ** Function BTA_DmSetLocalDiRecord
650 ** Description This function adds a DI record to the local SDP database.
652 ** Returns BTA_SUCCESS if record set sucessfully, otherwise error code.
654 *******************************************************************************/
655 tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info,
658 tBTA_STATUS status = BTA_FAILURE;
660 if(bta_dm_di_cb.di_num < BTA_DI_NUM_MAX)
662 if(SDP_SetLocalDiRecord((tSDP_DI_RECORD *)p_device_info, p_handle) == SDP_SUCCESS)
664 if(!p_device_info->primary_record)
666 bta_dm_di_cb.di_handle[bta_dm_di_cb.di_num] = *p_handle;
667 bta_dm_di_cb.di_num ++;
670 bta_sys_add_uuid(UUID_SERVCLASS_PNP_INFORMATION);
671 status = BTA_SUCCESS;
678 /*******************************************************************************
680 ** Function bta_dmexecutecallback
682 ** Description This function will request BTA to execute a call back in the context of BTU task
683 ** This API was named in lower case because it is only intended
684 ** for the internal customers(like BTIF).
688 *******************************************************************************/
689 void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK* p_callback, void * p_param)
691 tBTA_DM_API_EXECUTE_CBACK *p_msg;
693 if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
695 p_msg->hdr.event = BTA_DM_API_EXECUTE_CBACK_EVT;
696 p_msg->p_param= p_param;
697 p_msg->p_exec_cback= p_callback;
698 bta_sys_sendmsg(p_msg);
702 /*******************************************************************************
704 ** Function BTA_DmAddBleKey
706 ** Description Add/modify LE device information. This function will be
707 ** normally called during host startup to restore all required
708 ** information stored in the NVRAM.
710 ** Parameters: bd_addr - BD address of the peer
711 ** p_le_key - LE key values.
712 ** key_type - LE SMP key type.
714 ** Returns BTA_SUCCESS if successful
715 ** BTA_FAIL if operation failed.
717 *******************************************************************************/
718 void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_TYPE key_type)
720 #if BLE_INCLUDED == TRUE
722 tBTA_DM_API_ADD_BLEKEY *p_msg;
724 if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL)
726 memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLEKEY));
728 p_msg->hdr.event = BTA_DM_API_ADD_BLEKEY_EVT;
729 p_msg->key_type = key_type;
730 bdcpy(p_msg->bd_addr, bd_addr);
731 memcpy(&p_msg->blekey, p_le_key, sizeof(tBTA_LE_KEY_VALUE));
733 bta_sys_sendmsg(p_msg);
739 /*******************************************************************************
741 ** Function BTA_DmAddBleDevice
743 ** Description Add a BLE device. This function will be normally called
744 ** during host startup to restore all required information
745 ** for a LE device stored in the NVRAM.
747 ** Parameters: bd_addr - BD address of the peer
748 ** dev_type - Remote device's device type.
749 ** addr_type - LE device address type.
753 *******************************************************************************/
754 void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TYPE dev_type)
756 #if BLE_INCLUDED == TRUE
757 tBTA_DM_API_ADD_BLE_DEVICE *p_msg;
759 if ((p_msg = (tBTA_DM_API_ADD_BLE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLE_DEVICE))) != NULL)
761 memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLE_DEVICE));
763 p_msg->hdr.event = BTA_DM_API_ADD_BLEDEVICE_EVT;
764 bdcpy(p_msg->bd_addr, bd_addr);
765 p_msg->addr_type = addr_type;
766 p_msg->dev_type = dev_type;
768 bta_sys_sendmsg(p_msg);
772 /*******************************************************************************
774 ** Function BTA_DmBlePasskeyReply
776 ** Description Send BLE SMP passkey reply.
778 ** Parameters: bd_addr - BD address of the peer
779 ** accept - passkey entry sucessful or declined.
780 ** passkey - passkey value, must be a 6 digit number,
785 *******************************************************************************/
786 void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
788 #if BLE_INCLUDED == TRUE
789 tBTA_DM_API_PASSKEY_REPLY *p_msg;
791 if ((p_msg = (tBTA_DM_API_PASSKEY_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PASSKEY_REPLY))) != NULL)
793 memset(p_msg, 0, sizeof(tBTA_DM_API_PASSKEY_REPLY));
795 p_msg->hdr.event = BTA_DM_API_BLE_PASSKEY_REPLY_EVT;
796 bdcpy(p_msg->bd_addr, bd_addr);
797 p_msg->accept = accept;
801 p_msg->passkey = passkey;
803 bta_sys_sendmsg(p_msg);
807 /*******************************************************************************
809 ** Function BTA_DmBleConfirmReply
811 ** Description Send BLE SMP SC user confirmation reply.
813 ** Parameters: bd_addr - BD address of the peer
814 ** accept - numbers to compare are the same or different.
818 *******************************************************************************/
819 void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept)
821 #if BLE_INCLUDED == TRUE
822 tBTA_DM_API_CONFIRM *p_msg = (tBTA_DM_API_CONFIRM *)GKI_getbuf(sizeof(tBTA_DM_API_CONFIRM));
825 memset(p_msg, 0, sizeof(tBTA_DM_API_CONFIRM));
826 p_msg->hdr.event = BTA_DM_API_BLE_CONFIRM_REPLY_EVT;
827 bdcpy(p_msg->bd_addr, bd_addr);
828 p_msg->accept = accept;
829 bta_sys_sendmsg(p_msg);
834 /*******************************************************************************
836 ** Function BTA_DmBleSecurityGrant
838 ** Description Grant security request access.
840 ** Parameters: bd_addr - BD address of the peer
841 ** res - security grant status.
845 *******************************************************************************/
846 void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res)
848 #if BLE_INCLUDED == TRUE
849 tBTA_DM_API_BLE_SEC_GRANT *p_msg;
851 if ((p_msg = (tBTA_DM_API_BLE_SEC_GRANT *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SEC_GRANT))) != NULL)
853 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SEC_GRANT));
855 p_msg->hdr.event = BTA_DM_API_BLE_SEC_GRANT_EVT;
856 bdcpy(p_msg->bd_addr, bd_addr);
859 bta_sys_sendmsg(p_msg);
863 /*******************************************************************************
865 ** Function BTA_DmSetBlePrefConnParams
867 ** Description This function is called to set the preferred connection
868 ** parameters when default connection parameter is not desired.
870 ** Parameters: bd_addr - BD address of the peripheral
871 ** scan_interval - scan interval
872 ** scan_window - scan window
873 ** min_conn_int - minimum preferred connection interval
874 ** max_conn_int - maximum preferred connection interval
875 ** slave_latency - preferred slave latency
876 ** supervision_tout - preferred supervision timeout
881 *******************************************************************************/
882 void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr,
883 UINT16 min_conn_int, UINT16 max_conn_int,
884 UINT16 slave_latency, UINT16 supervision_tout )
886 #if BLE_INCLUDED == TRUE
887 tBTA_DM_API_BLE_CONN_PARAMS *p_msg;
889 if ((p_msg = (tBTA_DM_API_BLE_CONN_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_CONN_PARAMS))) != NULL)
891 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_CONN_PARAMS));
893 p_msg->hdr.event = BTA_DM_API_BLE_CONN_PARAM_EVT;
895 memcpy(p_msg->peer_bda, bd_addr, BD_ADDR_LEN);
897 p_msg->conn_int_max = max_conn_int;
898 p_msg->conn_int_min = min_conn_int;
899 p_msg->slave_latency = slave_latency;
900 p_msg->supervision_tout = supervision_tout;
902 bta_sys_sendmsg(p_msg);
907 /*******************************************************************************
909 ** Function BTA_DmSetBleConnScanParams
911 ** Description This function is called to set scan parameters used in
912 ** BLE connection request
914 ** Parameters: scan_interval - scan interval
915 ** scan_window - scan window
919 *******************************************************************************/
920 void BTA_DmSetBleConnScanParams(UINT32 scan_interval, UINT32 scan_window)
922 tBTA_DM_API_BLE_SCAN_PARAMS *p_msg;
923 if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
925 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS));
926 p_msg->hdr.event = BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT;
927 p_msg->scan_int = scan_interval;
928 p_msg->scan_window = scan_window;
929 bta_sys_sendmsg(p_msg);
933 /*******************************************************************************
935 ** Function BTA_DmSetBleScanParams
937 ** Description This function is called to set scan parameters
939 ** Parameters: client_if - Client IF
940 ** scan_interval - scan interval
941 ** scan_window - scan window
942 ** scan_mode - scan mode
943 ** scan_param_setup_status_cback - Set scan param status callback
947 *******************************************************************************/
948 void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
949 UINT32 scan_window, tBLE_SCAN_MODE scan_mode,
950 tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback)
952 tBTA_DM_API_BLE_SCAN_PARAMS *p_msg;
954 if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
956 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS));
957 p_msg->hdr.event = BTA_DM_API_BLE_SCAN_PARAM_EVT;
958 p_msg->client_if = client_if;
959 p_msg->scan_int = scan_interval;
960 p_msg->scan_window = scan_window;
961 p_msg->scan_mode = scan_mode;
962 p_msg->scan_param_setup_cback = scan_param_setup_cback;
964 bta_sys_sendmsg(p_msg);
968 /*******************************************************************************
970 ** Function BTA_DmSetBleAdvParams
972 ** Description This function sets the advertising parameters BLE functionality.
973 ** It is to be called when device act in peripheral or broadcaster
979 *******************************************************************************/
980 void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
981 tBLE_BD_ADDR *p_dir_bda)
983 #if BLE_INCLUDED == TRUE
984 tBTA_DM_API_BLE_ADV_PARAMS *p_msg;
986 APPL_TRACE_API ("BTA_DmSetBleAdvParam: %d, %d", adv_int_min, adv_int_max);
988 if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS))) != NULL)
990 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS));
992 p_msg->hdr.event = BTA_DM_API_BLE_ADV_PARAM_EVT;
994 p_msg->adv_int_min = adv_int_min;
995 p_msg->adv_int_max = adv_int_max;
997 if (p_dir_bda != NULL)
999 p_msg->p_dir_bda = (tBLE_BD_ADDR *)(p_msg + 1);
1000 memcpy(p_msg->p_dir_bda, p_dir_bda, sizeof(tBLE_BD_ADDR));
1003 bta_sys_sendmsg(p_msg);
1007 /*******************************************************************************
1008 ** BLE ADV data management API
1009 ********************************************************************************/
1011 #if BLE_INCLUDED == TRUE
1012 /*******************************************************************************
1014 ** Function BTA_DmBleSetAdvConfig
1016 ** Description This function is called to override the BTA default ADV parameters.
1018 ** Parameters data_mask: adv data mask.
1019 ** p_adv_cfg: Pointer to User defined ADV data structure. This
1020 ** memory space can not be freed until p_adv_data_cback
1022 ** p_adv_data_cback: set adv data complete callback.
1026 *******************************************************************************/
1027 void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
1028 tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
1030 tBTA_DM_API_SET_ADV_CONFIG *p_msg;
1032 if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG *)
1033 GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL)
1035 p_msg->hdr.event = BTA_DM_API_BLE_SET_ADV_CONFIG_EVT;
1036 p_msg->data_mask = data_mask;
1037 p_msg->p_adv_data_cback = p_adv_data_cback;
1038 p_msg->p_adv_cfg = p_adv_cfg;
1040 bta_sys_sendmsg(p_msg);
1044 /*******************************************************************************
1046 ** Function BTA_DmBleSetScanRsp
1048 ** Description This function is called to override the BTA scan response.
1050 ** Parameters Pointer to User defined ADV data structure
1054 *******************************************************************************/
1055 extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
1056 tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
1058 tBTA_DM_API_SET_ADV_CONFIG *p_msg;
1060 if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG *)
1061 GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL)
1063 p_msg->hdr.event = BTA_DM_API_BLE_SET_SCAN_RSP_EVT;
1064 p_msg->data_mask = data_mask;
1065 p_msg->p_adv_data_cback = p_adv_data_cback;
1066 p_msg->p_adv_cfg = p_adv_cfg;
1068 bta_sys_sendmsg(p_msg);
1072 /*******************************************************************************
1074 ** Function BTA_DmBleSetStorageParams
1076 ** Description This function is called to override the BTA scan response.
1078 ** Parameters batch_scan_full_max -Max storage space (in %) allocated to full scanning
1079 ** batch_scan_trunc_max -Max storage space (in %) allocated to truncated scanning
1080 ** batch_scan_notify_threshold -Setup notification level based on total space
1081 ** p_setup_cback - Setup callback pointer
1082 ** p_thres_cback - Threshold callback pointer
1083 ** p_rep_cback - Reports callback pointer
1084 ** ref_value - Ref value
1088 *******************************************************************************/
1089 extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max,
1090 UINT8 batch_scan_trunc_max,
1091 UINT8 batch_scan_notify_threshold,
1092 tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback,
1093 tBTA_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
1094 tBTA_BLE_SCAN_REP_CBACK* p_rep_cback,
1095 tBTA_DM_BLE_REF_VALUE ref_value)
1097 tBTA_DM_API_SET_STORAGE_CONFIG *p_msg;
1098 bta_dm_cb.p_setup_cback = p_setup_cback;
1099 if ((p_msg = (tBTA_DM_API_SET_STORAGE_CONFIG *)
1100 GKI_getbuf(sizeof(tBTA_DM_API_SET_STORAGE_CONFIG))) != NULL)
1102 p_msg->hdr.event = BTA_DM_API_BLE_SETUP_STORAGE_EVT;
1103 p_msg->p_setup_cback=bta_ble_scan_setup_cb;
1104 p_msg->p_thres_cback=p_thres_cback;
1105 p_msg->p_read_rep_cback=p_rep_cback;
1106 p_msg->ref_value = ref_value;
1107 p_msg->batch_scan_full_max = batch_scan_full_max;
1108 p_msg->batch_scan_trunc_max = batch_scan_trunc_max;
1109 p_msg->batch_scan_notify_threshold = batch_scan_notify_threshold;
1110 bta_sys_sendmsg(p_msg);
1114 /*******************************************************************************
1116 ** Function BTA_DmBleEnableBatchScan
1118 ** Description This function is called to enable the batch scan
1120 ** Parameters scan_mode -Batch scan mode
1121 ** scan_interval - Scan interval
1122 ** scan_window - Scan window
1123 ** discard_rule -Discard rules
1124 ** addr_type - Address type
1125 ** ref_value - Reference value
1129 *******************************************************************************/
1130 extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode,
1131 UINT32 scan_interval, UINT32 scan_window,
1132 tBTA_BLE_DISCARD_RULE discard_rule,
1133 tBLE_ADDR_TYPE addr_type,
1134 tBTA_DM_BLE_REF_VALUE ref_value)
1136 tBTA_DM_API_ENABLE_SCAN *p_msg;
1138 if ((p_msg = (tBTA_DM_API_ENABLE_SCAN *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE_SCAN))) != NULL)
1140 p_msg->hdr.event = BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT;
1141 p_msg->scan_mode = scan_mode;
1142 p_msg->scan_int = scan_interval;
1143 p_msg->scan_window = scan_window;
1144 p_msg->discard_rule = discard_rule;
1145 p_msg->addr_type = addr_type;
1146 p_msg->ref_value = ref_value;
1147 bta_sys_sendmsg(p_msg);
1151 /*******************************************************************************
1153 ** Function BTA_DmBleDisableBatchScan
1155 ** Description This function is called to disable the batch scan
1157 ** Parameters ref_value - Reference value
1161 *******************************************************************************/
1162 extern void BTA_DmBleDisableBatchScan(tBTA_DM_BLE_REF_VALUE ref_value)
1164 tBTA_DM_API_DISABLE_SCAN *p_msg;
1166 if ((p_msg = (tBTA_DM_API_DISABLE_SCAN *)
1167 GKI_getbuf(sizeof(tBTA_DM_API_DISABLE_SCAN))) != NULL)
1169 p_msg->hdr.event = BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT;
1170 p_msg->ref_value = ref_value;
1171 bta_sys_sendmsg(p_msg);
1175 /*******************************************************************************
1177 ** Function BTA_DmBleReadScanReports
1179 ** Description This function is called to read scan reports
1181 ** Parameters scan_type -Batch scan mode
1182 ** ref_value - Reference value
1186 *******************************************************************************/
1187 extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type,
1188 tBTA_DM_BLE_REF_VALUE ref_value)
1190 tBTA_DM_API_READ_SCAN_REPORTS *p_msg;
1192 if ((p_msg = (tBTA_DM_API_READ_SCAN_REPORTS *)
1193 GKI_getbuf(sizeof(tBTA_DM_API_READ_SCAN_REPORTS))) != NULL)
1195 p_msg->hdr.event = BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT;
1196 p_msg->scan_type = scan_type;
1197 p_msg->ref_value = ref_value;
1198 bta_sys_sendmsg(p_msg);
1202 /*******************************************************************************
1204 ** Function BTA_DmBleTrackAdvertiser
1206 ** Description This function is called to track advertiser
1208 ** Parameters ref_value - Reference value
1209 ** p_track_adv_cback - Track ADV callback
1213 *******************************************************************************/
1214 extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value,
1215 tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback)
1217 tBTA_DM_API_TRACK_ADVERTISER *p_msg;
1219 if ((p_msg = (tBTA_DM_API_TRACK_ADVERTISER *)
1220 GKI_getbuf(sizeof(tBTA_DM_API_TRACK_ADVERTISER))) != NULL)
1222 p_msg->hdr.event = BTA_DM_API_BLE_TRACK_ADVERTISER_EVT;
1223 p_msg->p_track_adv_cback = p_track_adv_cback;
1224 p_msg->ref_value = ref_value;
1225 bta_sys_sendmsg(p_msg);
1231 /*******************************************************************************
1232 ** BLE ADV data management API
1233 ********************************************************************************/
1234 #if BLE_INCLUDED == TRUE
1236 /*******************************************************************************
1238 ** Function BTA_DmBleBroadcast
1240 ** Description This function starts or stops LE broadcasting.
1242 ** Parameters start: start or stop broadcast.
1246 *******************************************************************************/
1247 extern void BTA_DmBleBroadcast (BOOLEAN start)
1249 tBTA_DM_API_BLE_OBSERVE *p_msg;
1251 APPL_TRACE_API("BTA_DmBleBroadcast: start = %d ", start);
1253 if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
1255 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
1257 p_msg->hdr.event = BTA_DM_API_BLE_BROADCAST_EVT;
1258 p_msg->start = start;
1260 bta_sys_sendmsg(p_msg);
1265 /*******************************************************************************
1267 ** Function BTA_DmBleSetBgConnType
1269 ** Description This function is called to set BLE connectable mode for a
1270 ** peripheral device.
1272 ** Parameters bg_conn_type: it can be auto connection, or selective connection.
1273 ** p_select_cback: callback function when selective connection procedure
1278 *******************************************************************************/
1279 void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_CBACK *p_select_cback)
1281 #if BLE_INCLUDED == TRUE
1282 tBTA_DM_API_BLE_SET_BG_CONN_TYPE *p_msg;
1284 if ((p_msg = (tBTA_DM_API_BLE_SET_BG_CONN_TYPE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE))) != NULL)
1286 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE));
1288 p_msg->hdr.event = BTA_DM_API_BLE_SET_BG_CONN_TYPE;
1289 p_msg->bg_conn_type = bg_conn_type;
1290 p_msg->p_select_cback = p_select_cback;
1292 bta_sys_sendmsg(p_msg);
1297 /*******************************************************************************
1299 ** Function bta_dm_discover_send_msg
1301 ** Description This function send discover message to BTA task.
1305 *******************************************************************************/
1306 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1307 static void bta_dm_discover_send_msg(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
1308 tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search,
1309 tBTA_TRANSPORT transport)
1311 tBTA_DM_API_DISCOVER *p_msg;
1312 UINT16 len = p_services ? (sizeof(tBTA_DM_API_DISCOVER) +
1313 sizeof(tBT_UUID) * p_services->num_uuid) :
1314 sizeof(tBTA_DM_API_DISCOVER);
1316 if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(len)) != NULL)
1318 memset(p_msg, 0, len);
1320 p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
1321 bdcpy(p_msg->bd_addr, bd_addr);
1322 p_msg->p_cback = p_cback;
1323 p_msg->sdp_search = sdp_search;
1324 p_msg->transport = transport;
1326 if (p_services != NULL)
1328 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1329 p_msg->services = p_services->srvc_mask;
1330 p_msg->num_uuid = p_services->num_uuid;
1331 if (p_services->num_uuid != 0)
1333 p_msg->p_uuid = (tBT_UUID *)(p_msg + 1);
1334 memcpy(p_msg->p_uuid, p_services->p_uuid, sizeof(tBT_UUID) * p_services->num_uuid);
1339 bta_sys_sendmsg(p_msg);
1343 /*******************************************************************************
1345 ** Function BTA_DmDiscoverByTransport
1347 ** Description This function does service discovery on particular transport
1348 ** for services of a
1349 ** peer device. When services.num_uuid is 0, it indicates all
1350 ** GATT based services are to be searched; otherwise a list of
1351 ** UUID of interested services should be provided through
1352 ** p_services->p_uuid.
1358 *******************************************************************************/
1359 void BTA_DmDiscoverByTransport(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
1360 tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search,
1361 tBTA_TRANSPORT transport)
1363 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1364 bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, transport);
1369 /*******************************************************************************
1371 ** Function BTA_DmDiscoverExt
1373 ** Description This function does service discovery for services of a
1374 ** peer device. When services.num_uuid is 0, it indicates all
1375 ** GATT based services are to be searched; other wise a list of
1376 ** UUID of interested services should be provided through
1377 ** p_services->p_uuid.
1383 *******************************************************************************/
1384 void BTA_DmDiscoverExt(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
1385 tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search)
1387 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1388 bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, BTA_TRANSPORT_UNKNOWN);
1393 /*******************************************************************************
1395 ** Function BTA_DmSearchExt
1397 ** Description This function searches for peer Bluetooth devices. It performs
1398 ** an inquiry and gets the remote name for devices. Service
1399 ** discovery is done if services is non zero
1401 ** Parameters p_dm_inq: inquiry conditions
1402 ** p_services: if service is not empty, service discovery will be done.
1403 ** for all GATT based service condition, put num_uuid, and
1404 ** p_uuid is the pointer to the list of UUID values.
1405 ** p_cback: callback functino when search is completed.
1411 *******************************************************************************/
1412 void BTA_DmSearchExt(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK_EXT *p_services, tBTA_DM_SEARCH_CBACK *p_cback)
1414 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1415 tBTA_DM_API_SEARCH *p_msg;
1416 UINT16 len = p_services ? (sizeof(tBTA_DM_API_SEARCH) + sizeof(tBT_UUID) * p_services->num_uuid) :
1417 sizeof(tBTA_DM_API_SEARCH);
1419 if ((p_msg = (tBTA_DM_API_SEARCH *) GKI_getbuf(len)) != NULL)
1421 memset(p_msg, 0, len);
1423 p_msg->hdr.event = BTA_DM_API_SEARCH_EVT;
1424 memcpy(&p_msg->inq_params, p_dm_inq, sizeof(tBTA_DM_INQ));
1425 p_msg->p_cback = p_cback;
1426 p_msg->rs_res = BTA_DM_RS_NONE;
1429 if (p_services != NULL)
1431 p_msg->services = p_services->srvc_mask;
1432 p_msg->num_uuid = p_services->num_uuid;
1434 if (p_services->num_uuid != 0)
1436 p_msg->p_uuid = (tBT_UUID *)(p_msg + 1);
1437 memcpy(p_msg->p_uuid, p_services->p_uuid, sizeof(tBT_UUID) * p_services->num_uuid);
1440 p_msg->p_uuid = NULL;
1443 bta_sys_sendmsg(p_msg);
1451 /*******************************************************************************
1453 ** Function BTA_DmBleUpdateConnectionParam
1455 ** Description Update connection parameters, can only be used when connection is up.
1457 ** Parameters: bd_addr - BD address of the peer
1458 ** min_int - minimum connection interval, [0x0004~ 0x4000]
1459 ** max_int - maximum connection interval, [0x0004~ 0x4000]
1460 ** latency - slave latency [0 ~ 500]
1461 ** timeout - supervision timeout [0x000a ~ 0xc80]
1465 *******************************************************************************/
1466 void BTA_DmBleUpdateConnectionParam(BD_ADDR bd_addr, UINT16 min_int,
1467 UINT16 max_int, UINT16 latency,
1470 #if BLE_INCLUDED == TRUE
1471 tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
1473 p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
1476 memset(p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
1478 p_msg->hdr.event = BTA_DM_API_UPDATE_CONN_PARAM_EVT;
1479 bdcpy(p_msg->bd_addr, bd_addr);
1480 p_msg->min_int = min_int;
1481 p_msg->max_int = max_int;
1482 p_msg->latency = latency;
1483 p_msg->timeout = timeout;
1485 bta_sys_sendmsg(p_msg);
1489 /*******************************************************************************
1491 ** Function BTA_DmBleConfigLocalPrivacy
1493 ** Description Enable/disable privacy on the local device
1495 ** Parameters: privacy_enable - enable/disabe privacy on remote device.
1499 *******************************************************************************/
1500 void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable)
1502 #if BLE_INCLUDED == TRUE && BLE_PRIVACY_SPT == TRUE
1503 tBTA_DM_API_LOCAL_PRIVACY *p_msg;
1505 if ((p_msg = (tBTA_DM_API_LOCAL_PRIVACY *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE_PRIVACY))) != NULL)
1507 memset (p_msg, 0, sizeof(tBTA_DM_API_LOCAL_PRIVACY));
1509 p_msg->hdr.event = BTA_DM_API_LOCAL_PRIVACY_EVT;
1510 p_msg->privacy_enable = privacy_enable;
1512 bta_sys_sendmsg(p_msg);
1515 UNUSED (privacy_enable);
1519 #if BLE_INCLUDED == TRUE
1520 /*******************************************************************************
1522 ** Function BTA_BleEnableAdvInstance
1524 ** Description This function enable a Multi-ADV instance with the specififed
1527 ** Parameters p_params: pointer to the adv parameter structure.
1528 ** p_cback: callback function associated to this adv instance.
1529 ** p_ref: reference data pointer to this adv instance.
1531 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1533 *******************************************************************************/
1534 void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
1535 tBTA_BLE_MULTI_ADV_CBACK *p_cback,
1538 tBTA_DM_API_BLE_MULTI_ADV_ENB *p_msg;
1539 UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB);
1541 APPL_TRACE_API ("BTA_BleEnableAdvInstance");
1543 if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_ENB *) GKI_getbuf(len)) != NULL)
1545 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB));
1547 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_ENB_EVT;
1548 p_msg->p_cback = (void *)p_cback;
1549 if (p_params != NULL)
1551 p_msg->p_params = (void *)(p_msg + 1);
1552 memcpy(p_msg->p_params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
1554 p_msg->p_ref = p_ref;
1556 bta_sys_sendmsg(p_msg);
1560 /*******************************************************************************
1562 ** Function BTA_BleUpdateAdvInstParam
1564 ** Description This function update a Multi-ADV instance with the specififed
1567 ** Parameters inst_id: Adv instance to update the parameter.
1568 ** p_params: pointer to the adv parameter structure.
1570 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1572 *******************************************************************************/
1573 void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
1575 tBTA_DM_API_BLE_MULTI_ADV_PARAM *p_msg;
1576 UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM);
1578 APPL_TRACE_API ("BTA_BleUpdateAdvInstParam");
1579 if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_PARAM *) GKI_getbuf(len)) != NULL)
1581 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM));
1582 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT;
1583 p_msg->inst_id = inst_id;
1584 p_msg->p_params = (void *)(p_msg + 1);
1585 memcpy(p_msg->p_params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
1587 bta_sys_sendmsg(p_msg);
1591 /*******************************************************************************
1593 ** Function BTA_BleCfgAdvInstData
1595 ** Description This function configure a Multi-ADV instance with the specififed
1596 ** adv data or scan response data.
1598 ** Parameter inst_id: Adv instance to configure the adv data or scan response.
1599 ** is_scan_rsp: is the data scan response or adv data.
1600 ** data_mask: adv data type as bit mask.
1601 ** p_data: pointer to the ADV data structure tBTA_BLE_ADV_DATA. This
1602 ** memory space can not be freed until BTA_BLE_MULTI_ADV_DATA_EVT
1603 ** is sent to application.
1605 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1607 *******************************************************************************/
1608 void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
1609 tBTA_BLE_AD_MASK data_mask,
1610 tBTA_BLE_ADV_DATA *p_data)
1612 tBTA_DM_API_BLE_MULTI_ADV_DATA *p_msg;
1613 UINT16 len = sizeof(tBTA_DM_API_BLE_MULTI_ADV_DATA) ;
1615 APPL_TRACE_API ("BTA_BleCfgAdvInstData");
1617 if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DATA *) GKI_getbuf(len)) != NULL)
1619 memset(p_msg, 0, len);
1620 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_DATA_EVT;
1621 p_msg->inst_id = inst_id;
1622 p_msg->is_scan_rsp = is_scan_rsp;
1623 p_msg->data_mask = data_mask;
1624 p_msg->p_data = p_data;
1626 bta_sys_sendmsg(p_msg);
1630 /*******************************************************************************
1632 ** Function BTA_BleDisableAdvInstance
1634 ** Description This function disable a Multi-ADV instance.
1636 ** Parameter inst_id: instance ID to disable.
1638 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1640 *******************************************************************************/
1641 void BTA_BleDisableAdvInstance (UINT8 inst_id)
1643 tBTA_DM_API_BLE_MULTI_ADV_DISABLE *p_msg;
1645 APPL_TRACE_API ("BTA_BleDisableAdvInstance: %d", inst_id);
1646 if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DISABLE *)
1647 GKI_getbuf(sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE))) != NULL)
1649 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE));
1650 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT;
1651 p_msg->inst_id = inst_id;
1652 bta_sys_sendmsg(p_msg);
1656 /*******************************************************************************
1658 ** Function BTA_DmBleCfgFilterCondition
1660 ** Description This function is called to configure the adv data payload filter
1663 ** Parameters action: to read/write/clear
1664 ** cond_type: filter condition type
1665 ** filt_index - Filter index
1666 ** p_cond: filter condition parameter
1667 ** p_cmpl_back - Command completed callback
1668 ** ref_value - Reference value
1672 *******************************************************************************/
1673 void BTA_DmBleCfgFilterCondition(tBTA_DM_BLE_SCAN_COND_OP action,
1674 tBTA_DM_BLE_PF_COND_TYPE cond_type,
1675 tBTA_DM_BLE_PF_FILT_INDEX filt_index,
1676 tBTA_DM_BLE_PF_COND_PARAM *p_cond,
1677 tBTA_DM_BLE_PF_CFG_CBACK *p_cmpl_cback,
1678 tBTA_DM_BLE_REF_VALUE ref_value)
1680 #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
1681 tBTA_DM_API_CFG_FILTER_COND *p_msg;
1682 APPL_TRACE_API ("BTA_DmBleCfgFilterCondition: %d, %d", action, cond_type);
1684 UINT16 len = sizeof(tBTA_DM_API_CFG_FILTER_COND) +
1685 sizeof(tBTA_DM_BLE_PF_COND_PARAM);
1692 case BTA_DM_BLE_PF_SRVC_DATA_PATTERN:
1693 case BTA_DM_BLE_PF_MANU_DATA:
1694 /* Length of pattern and pattern mask and other elements in */
1695 /* tBTA_DM_BLE_PF_MANU_COND */
1696 len += ((p_cond->manu_data.data_len) * 2) +
1697 sizeof(UINT16) + sizeof(UINT16) + sizeof(UINT8);
1700 case BTA_DM_BLE_PF_LOCAL_NAME:
1701 len += ((p_cond->local_name.data_len) + sizeof(UINT8));
1704 case BTM_BLE_PF_SRVC_UUID:
1705 case BTM_BLE_PF_SRVC_SOL_UUID:
1706 len += sizeof(tBLE_BD_ADDR) + sizeof(tBTA_DM_BLE_PF_COND_MASK);
1714 if ((p_msg = (tBTA_DM_API_CFG_FILTER_COND *) GKI_getbuf(len)) != NULL)
1716 memset (p_msg, 0, len);
1718 p_msg->hdr.event = BTA_DM_API_CFG_FILTER_COND_EVT;
1719 p_msg->action = action;
1720 p_msg->cond_type = cond_type;
1721 p_msg->filt_index = filt_index;
1722 p_msg->p_filt_cfg_cback = p_cmpl_cback;
1723 p_msg->ref_value = ref_value;
1726 p_msg->p_cond_param = (tBTA_DM_BLE_PF_COND_PARAM *)(p_msg + 1);
1727 memcpy(p_msg->p_cond_param, p_cond, sizeof(tBTA_DM_BLE_PF_COND_PARAM));
1729 p = (UINT8 *)(p_msg->p_cond_param + 1);
1731 if (cond_type == BTA_DM_BLE_PF_SRVC_DATA_PATTERN ||
1732 cond_type == BTA_DM_BLE_PF_MANU_DATA)
1734 p_msg->p_cond_param->manu_data.p_pattern = p;
1735 p_msg->p_cond_param->manu_data.data_len = p_cond->manu_data.data_len;
1736 memcpy(p_msg->p_cond_param->manu_data.p_pattern, p_cond->manu_data.p_pattern,
1737 p_cond->manu_data.data_len);
1738 p += p_cond->manu_data.data_len;
1740 if (cond_type == BTA_DM_BLE_PF_MANU_DATA)
1742 p_msg->p_cond_param->manu_data.company_id_mask =
1743 p_cond->manu_data.company_id_mask;
1744 if ( p_cond->manu_data.p_pattern_mask != NULL)
1746 p_msg->p_cond_param->manu_data.p_pattern_mask = p;
1747 memcpy(p_msg->p_cond_param->manu_data.p_pattern_mask,
1748 p_cond->manu_data.p_pattern_mask, p_cond->manu_data.data_len);
1752 else if (cond_type == BTA_DM_BLE_PF_LOCAL_NAME)
1754 p_msg->p_cond_param->local_name.p_data = p;
1755 p_msg->p_cond_param->local_name.data_len =
1756 p_cond->local_name.data_len;
1757 memcpy(p_msg->p_cond_param->local_name.p_data,
1758 p_cond->local_name.p_data, p_cond->local_name.data_len);
1760 else if ((cond_type == BTM_BLE_PF_SRVC_UUID
1761 || cond_type == BTM_BLE_PF_SRVC_SOL_UUID))
1763 if (p_cond->srvc_uuid.p_target_addr != NULL)
1765 p_msg->p_cond_param->srvc_uuid.p_target_addr = (tBLE_BD_ADDR *)(p);
1766 p_msg->p_cond_param->srvc_uuid.p_target_addr->type =
1767 p_cond->srvc_uuid.p_target_addr->type;
1768 memcpy(p_msg->p_cond_param->srvc_uuid.p_target_addr->bda,
1769 p_cond->srvc_uuid.p_target_addr->bda, BD_ADDR_LEN);
1770 p = (UINT8*)( p_msg->p_cond_param->srvc_uuid.p_target_addr + 1);
1772 if (p_cond->srvc_uuid.p_uuid_mask)
1774 p_msg->p_cond_param->srvc_uuid.p_uuid_mask = (tBTA_DM_BLE_PF_COND_MASK *)p;
1775 memcpy(p_msg->p_cond_param->srvc_uuid.p_uuid_mask,
1776 p_cond->srvc_uuid.p_uuid_mask, sizeof(tBTA_DM_BLE_PF_COND_MASK));
1781 bta_sys_sendmsg(p_msg);
1788 UNUSED(p_cmpl_cback);
1793 /*******************************************************************************
1795 ** Function BTA_DmBleScanFilterSetup
1797 ** Description This function is called to setup the adv data payload filter param
1799 ** Parameters p_target: enable the filter condition on a target device; if NULL
1800 ** filt_index - Filter index
1801 ** p_filt_params -Filter parameters
1802 ** ref_value - Reference value
1803 ** action - Add, delete or clear
1804 ** p_cmpl_back - Command completed callback
1808 *******************************************************************************/
1809 void BTA_DmBleScanFilterSetup(UINT8 action, tBTA_DM_BLE_PF_FILT_INDEX filt_index,
1810 tBTA_DM_BLE_PF_FILT_PARAMS *p_filt_params,
1811 tBLE_BD_ADDR *p_target,
1812 tBTA_DM_BLE_PF_PARAM_CBACK *p_cmpl_cback,
1813 tBTA_DM_BLE_REF_VALUE ref_value)
1815 #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
1816 tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *p_msg;
1817 APPL_TRACE_API ("BTA_DmBleScanFilterSetup: %d", action);
1819 UINT16 len = sizeof(tBTA_DM_API_SCAN_FILTER_PARAM_SETUP) + sizeof(tBLE_BD_ADDR);
1821 if ((p_msg = (tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *) GKI_getbuf(len)) != NULL)
1823 memset (p_msg, 0, len);
1825 p_msg->hdr.event = BTA_DM_API_SCAN_FILTER_SETUP_EVT;
1826 p_msg->action = action;
1827 p_msg->filt_index = filt_index;
1829 memcpy(&p_msg->filt_params, p_filt_params, sizeof(tBTA_DM_BLE_PF_FILT_PARAMS));
1830 p_msg->p_filt_param_cback = p_cmpl_cback;
1831 p_msg->ref_value = ref_value;
1835 p_msg->p_target = (tBLE_BD_ADDR *)(p_msg + 1);
1836 memcpy(p_msg->p_target, p_target, sizeof(tBLE_BD_ADDR));
1839 bta_sys_sendmsg(p_msg);
1844 UNUSED(p_filt_params);
1846 UNUSED(p_cmpl_cback);
1851 /*******************************************************************************
1853 ** Function BTA_DmBleGetEnergyInfo
1855 ** Description This function is called to obtain the energy info
1857 ** Parameters p_cmpl_cback - Command complete callback
1861 *******************************************************************************/
1862 void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK *p_cmpl_cback)
1864 tBTA_DM_API_ENERGY_INFO *p_msg;
1865 APPL_TRACE_API ("BTA_DmBleGetEnergyInfo");
1867 UINT16 len = sizeof(tBTA_DM_API_ENERGY_INFO) + sizeof(tBLE_BD_ADDR);
1869 if ((p_msg = (tBTA_DM_API_ENERGY_INFO *) GKI_getbuf(len)) != NULL)
1871 memset (p_msg, 0, len);
1872 p_msg->hdr.event = BTA_DM_API_BLE_ENERGY_INFO_EVT;
1873 p_msg->p_energy_info_cback = p_cmpl_cback;
1874 bta_sys_sendmsg(p_msg);
1878 /*******************************************************************************
1880 ** Function BTA_DmEnableScanFilter
1882 ** Description This function is called to enable the adv data payload filter
1884 ** Parameters action - enable or disable the APCF feature
1885 ** p_cmpl_cback - Command completed callback
1886 ** ref_value - Reference value
1890 *******************************************************************************/
1891 void BTA_DmEnableScanFilter(UINT8 action, tBTA_DM_BLE_PF_STATUS_CBACK *p_cmpl_cback,
1892 tBTA_DM_BLE_REF_VALUE ref_value)
1894 #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
1895 tBTA_DM_API_ENABLE_SCAN_FILTER *p_msg;
1896 APPL_TRACE_API ("BTA_DmEnableScanFilter: %d", action);
1898 UINT16 len = sizeof(tBTA_DM_API_ENABLE_SCAN_FILTER) + sizeof(tBLE_BD_ADDR);
1900 if ((p_msg = (tBTA_DM_API_ENABLE_SCAN_FILTER *) GKI_getbuf(len)) != NULL)
1902 memset (p_msg, 0, len);
1904 p_msg->hdr.event = BTA_DM_API_SCAN_FILTER_ENABLE_EVT;
1905 p_msg->action = action;
1906 p_msg->ref_value = ref_value;
1907 p_msg->p_filt_status_cback = p_cmpl_cback;
1909 bta_sys_sendmsg(p_msg);
1913 UNUSED(p_cmpl_cback);
1918 /*******************************************************************************
1920 ** Function BTA_DmBleUpdateConnectionParams
1922 ** Description Update connection parameters, can only be used when connection is up.
1924 ** Parameters: bd_addr - BD address of the peer
1925 ** min_int - minimum connection interval, [0x0004~ 0x4000]
1926 ** max_int - maximum connection interval, [0x0004~ 0x4000]
1927 ** latency - slave latency [0 ~ 500]
1928 ** timeout - supervision timeout [0x000a ~ 0xc80]
1932 *******************************************************************************/
1933 void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, UINT16 max_int,
1934 UINT16 latency, UINT16 timeout)
1936 tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
1938 if ((p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM))) != NULL)
1940 memset (p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
1942 p_msg->hdr.event = BTA_DM_API_UPDATE_CONN_PARAM_EVT;
1943 bdcpy(p_msg->bd_addr, bd_addr);
1944 p_msg->min_int = min_int;
1945 p_msg->max_int = max_int;
1946 p_msg->latency = latency;
1947 p_msg->timeout = timeout;
1949 bta_sys_sendmsg(p_msg);
1953 /*******************************************************************************
1955 ** Function BTA_DmBleSetDataLength
1957 ** Description This function is to set maximum LE data packet size
1962 *******************************************************************************/
1963 void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length)
1965 tBTA_DM_API_BLE_SET_DATA_LENGTH *p_msg;
1967 if ((p_msg = (tBTA_DM_API_BLE_SET_DATA_LENGTH *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SET_DATA_LENGTH)))
1970 bdcpy(p_msg->remote_bda, remote_device);
1971 p_msg->hdr.event = BTA_DM_API_SET_DATA_LENGTH_EVT;
1972 p_msg->tx_data_length = tx_data_length;
1974 bta_sys_sendmsg(p_msg);
1980 /*******************************************************************************
1982 ** Function BTA_DmSetEncryption
1984 ** Description This function is called to ensure that connection is
1985 ** encrypted. Should be called only on an open connection.
1986 ** Typically only needed for connections that first want to
1987 ** bring up unencrypted links, then later encrypt them.
1989 ** Parameters: bd_addr - Address of the peer device
1990 ** transport - transport of the link to be encruypted
1991 ** p_callback - Pointer to callback function to indicat the
1992 ** link encryption status
1993 ** sec_act - This is the security action to indicate
1994 ** what knid of BLE security level is required for
1995 ** the BLE link if the BLE is supported
1996 ** Note: This parameter is ignored for the BR/EDR link
1997 ** or the BLE is not supported
2001 *******************************************************************************/
2002 void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCRYPT_CBACK *p_callback,
2003 tBTA_DM_BLE_SEC_ACT sec_act)
2005 tBTA_DM_API_SET_ENCRYPTION *p_msg;
2007 APPL_TRACE_API("BTA_DmSetEncryption"); //todo
2008 if ((p_msg = (tBTA_DM_API_SET_ENCRYPTION *) GKI_getbuf(sizeof(tBTA_DM_API_SET_ENCRYPTION))) != NULL)
2010 memset(p_msg, 0, sizeof(tBTA_DM_API_SET_ENCRYPTION));
2012 p_msg->hdr.event = BTA_DM_API_SET_ENCRYPTION_EVT;
2014 memcpy(p_msg->bd_addr, bd_addr, BD_ADDR_LEN);
2015 p_msg->transport = transport;
2016 p_msg->p_callback = p_callback;
2017 p_msg->sec_act = sec_act;
2019 bta_sys_sendmsg(p_msg);
2023 /*******************************************************************************
2025 ** Function BTA_DmCloseACL
2027 ** Description This function force to close an ACL connection and remove the
2028 ** device from the security database list of known devices.
2030 ** Parameters: bd_addr - Address of the peer device
2031 ** remove_dev - remove device or not after link down
2035 *******************************************************************************/
2036 void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev, tBTA_TRANSPORT transport)
2038 tBTA_DM_API_REMOVE_ACL *p_msg;
2040 APPL_TRACE_API("BTA_DmCloseACL");
2042 if ((p_msg = (tBTA_DM_API_REMOVE_ACL *) GKI_getbuf(sizeof(tBTA_DM_API_REMOVE_ACL))) != NULL)
2044 memset(p_msg, 0, sizeof(tBTA_DM_API_REMOVE_ACL));
2046 p_msg->hdr.event = BTA_DM_API_REMOVE_ACL_EVT;
2048 memcpy(p_msg->bd_addr, bd_addr, BD_ADDR_LEN);
2049 p_msg->remove_dev = remove_dev;
2050 p_msg->transport = transport;
2052 bta_sys_sendmsg(p_msg);
2056 #if BLE_INCLUDED == TRUE
2057 /*******************************************************************************
2059 ** Function BTA_DmBleObserve
2061 ** Description This procedure keep the device listening for advertising
2062 ** events from a broadcast device.
2064 ** Parameters start: start or stop observe.
2071 *******************************************************************************/
2072 extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
2073 tBTA_DM_SEARCH_CBACK *p_results_cb)
2075 tBTA_DM_API_BLE_OBSERVE *p_msg;
2077 APPL_TRACE_API("BTA_DmBleObserve:start = %d ", start);
2079 if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
2081 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
2083 p_msg->hdr.event = BTA_DM_API_BLE_OBSERVE_EVT;
2084 p_msg->start = start;
2085 p_msg->duration = duration;
2086 p_msg->p_cback = p_results_cb;
2088 bta_sys_sendmsg(p_msg);
2092 /*******************************************************************************
2094 ** Function BTA_VendorInit
2096 ** Description This function initializes vendor specific
2100 *******************************************************************************/
2101 void BTA_VendorInit (void)
2103 APPL_TRACE_API("BTA_VendorInit");
2106 /*******************************************************************************
2108 ** Function BTA_VendorCleanup
2110 ** Description This function frees up Broadcom specific VS specific dynamic memory
2114 *******************************************************************************/
2115 void BTA_VendorCleanup (void)
2117 tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
2118 BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
2120 #if (BLE_INCLUDED == TRUE && BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE)
2121 if (cmn_ble_vsc_cb.max_filter > 0)
2123 btm_ble_adv_filter_cleanup();
2124 #if BLE_PRIVACY_SPT == TRUE
2125 btm_ble_resolving_list_cleanup ();
2129 if (cmn_ble_vsc_cb.tot_scan_results_strg > 0)
2130 btm_ble_batchscan_cleanup();
2133 if(cmn_ble_vsc_cb.adv_inst_max > 0)
2134 btm_ble_multi_adv_cleanup();