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 = GKI_getbuf(sizeof(*p_msg));
1033 memset(p_msg, 0, sizeof(*p_msg));
1034 p_msg->hdr.event = BTA_DM_API_BLE_SET_ADV_CONFIG_EVT;
1035 p_msg->data_mask = data_mask;
1036 p_msg->p_adv_data_cback = p_adv_data_cback;
1037 memcpy(&p_msg->adv_cfg, p_adv_cfg, sizeof(p_msg->adv_cfg));
1038 bta_sys_sendmsg(p_msg);
1041 /*******************************************************************************
1043 ** Function BTA_DmBleSetScanRsp
1045 ** Description This function is called to override the BTA scan response.
1047 ** Parameters Pointer to User defined ADV data structure
1051 *******************************************************************************/
1052 extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
1053 tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
1055 tBTA_DM_API_SET_ADV_CONFIG *p_msg = GKI_getbuf(sizeof(*p_msg));
1058 memset(p_msg, 0, sizeof(*p_msg));
1059 p_msg->hdr.event = BTA_DM_API_BLE_SET_SCAN_RSP_EVT;
1060 p_msg->data_mask = data_mask;
1061 p_msg->p_adv_data_cback = p_adv_data_cback;
1062 memcpy(&p_msg->adv_cfg, p_adv_cfg, sizeof(p_msg->adv_cfg));
1063 bta_sys_sendmsg(p_msg);
1066 /*******************************************************************************
1068 ** Function BTA_DmBleSetStorageParams
1070 ** Description This function is called to override the BTA scan response.
1072 ** Parameters batch_scan_full_max -Max storage space (in %) allocated to full scanning
1073 ** batch_scan_trunc_max -Max storage space (in %) allocated to truncated scanning
1074 ** batch_scan_notify_threshold -Setup notification level based on total space
1075 ** p_setup_cback - Setup callback pointer
1076 ** p_thres_cback - Threshold callback pointer
1077 ** p_rep_cback - Reports callback pointer
1078 ** ref_value - Ref value
1082 *******************************************************************************/
1083 extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max,
1084 UINT8 batch_scan_trunc_max,
1085 UINT8 batch_scan_notify_threshold,
1086 tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback,
1087 tBTA_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
1088 tBTA_BLE_SCAN_REP_CBACK* p_rep_cback,
1089 tBTA_DM_BLE_REF_VALUE ref_value)
1091 tBTA_DM_API_SET_STORAGE_CONFIG *p_msg;
1092 bta_dm_cb.p_setup_cback = p_setup_cback;
1093 if ((p_msg = (tBTA_DM_API_SET_STORAGE_CONFIG *)
1094 GKI_getbuf(sizeof(tBTA_DM_API_SET_STORAGE_CONFIG))) != NULL)
1096 p_msg->hdr.event = BTA_DM_API_BLE_SETUP_STORAGE_EVT;
1097 p_msg->p_setup_cback=bta_ble_scan_setup_cb;
1098 p_msg->p_thres_cback=p_thres_cback;
1099 p_msg->p_read_rep_cback=p_rep_cback;
1100 p_msg->ref_value = ref_value;
1101 p_msg->batch_scan_full_max = batch_scan_full_max;
1102 p_msg->batch_scan_trunc_max = batch_scan_trunc_max;
1103 p_msg->batch_scan_notify_threshold = batch_scan_notify_threshold;
1104 bta_sys_sendmsg(p_msg);
1108 /*******************************************************************************
1110 ** Function BTA_DmBleEnableBatchScan
1112 ** Description This function is called to enable the batch scan
1114 ** Parameters scan_mode -Batch scan mode
1115 ** scan_interval - Scan interval
1116 ** scan_window - Scan window
1117 ** discard_rule -Discard rules
1118 ** addr_type - Address type
1119 ** ref_value - Reference value
1123 *******************************************************************************/
1124 extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode,
1125 UINT32 scan_interval, UINT32 scan_window,
1126 tBTA_BLE_DISCARD_RULE discard_rule,
1127 tBLE_ADDR_TYPE addr_type,
1128 tBTA_DM_BLE_REF_VALUE ref_value)
1130 tBTA_DM_API_ENABLE_SCAN *p_msg;
1132 if ((p_msg = (tBTA_DM_API_ENABLE_SCAN *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE_SCAN))) != NULL)
1134 p_msg->hdr.event = BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT;
1135 p_msg->scan_mode = scan_mode;
1136 p_msg->scan_int = scan_interval;
1137 p_msg->scan_window = scan_window;
1138 p_msg->discard_rule = discard_rule;
1139 p_msg->addr_type = addr_type;
1140 p_msg->ref_value = ref_value;
1141 bta_sys_sendmsg(p_msg);
1145 /*******************************************************************************
1147 ** Function BTA_DmBleDisableBatchScan
1149 ** Description This function is called to disable the batch scan
1151 ** Parameters ref_value - Reference value
1155 *******************************************************************************/
1156 extern void BTA_DmBleDisableBatchScan(tBTA_DM_BLE_REF_VALUE ref_value)
1158 tBTA_DM_API_DISABLE_SCAN *p_msg;
1160 if ((p_msg = (tBTA_DM_API_DISABLE_SCAN *)
1161 GKI_getbuf(sizeof(tBTA_DM_API_DISABLE_SCAN))) != NULL)
1163 p_msg->hdr.event = BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT;
1164 p_msg->ref_value = ref_value;
1165 bta_sys_sendmsg(p_msg);
1169 /*******************************************************************************
1171 ** Function BTA_DmBleReadScanReports
1173 ** Description This function is called to read scan reports
1175 ** Parameters scan_type -Batch scan mode
1176 ** ref_value - Reference value
1180 *******************************************************************************/
1181 extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type,
1182 tBTA_DM_BLE_REF_VALUE ref_value)
1184 tBTA_DM_API_READ_SCAN_REPORTS *p_msg;
1186 if ((p_msg = (tBTA_DM_API_READ_SCAN_REPORTS *)
1187 GKI_getbuf(sizeof(tBTA_DM_API_READ_SCAN_REPORTS))) != NULL)
1189 p_msg->hdr.event = BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT;
1190 p_msg->scan_type = scan_type;
1191 p_msg->ref_value = ref_value;
1192 bta_sys_sendmsg(p_msg);
1196 /*******************************************************************************
1198 ** Function BTA_DmBleTrackAdvertiser
1200 ** Description This function is called to track advertiser
1202 ** Parameters ref_value - Reference value
1203 ** p_track_adv_cback - Track ADV callback
1207 *******************************************************************************/
1208 extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value,
1209 tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback)
1211 tBTA_DM_API_TRACK_ADVERTISER *p_msg;
1213 if ((p_msg = (tBTA_DM_API_TRACK_ADVERTISER *)
1214 GKI_getbuf(sizeof(tBTA_DM_API_TRACK_ADVERTISER))) != NULL)
1216 p_msg->hdr.event = BTA_DM_API_BLE_TRACK_ADVERTISER_EVT;
1217 p_msg->p_track_adv_cback = p_track_adv_cback;
1218 p_msg->ref_value = ref_value;
1219 bta_sys_sendmsg(p_msg);
1225 /*******************************************************************************
1226 ** BLE ADV data management API
1227 ********************************************************************************/
1228 #if BLE_INCLUDED == TRUE
1230 /*******************************************************************************
1232 ** Function BTA_DmBleBroadcast
1234 ** Description This function starts or stops LE broadcasting.
1236 ** Parameters start: start or stop broadcast.
1240 *******************************************************************************/
1241 extern void BTA_DmBleBroadcast (BOOLEAN start)
1243 tBTA_DM_API_BLE_OBSERVE *p_msg;
1245 APPL_TRACE_API("BTA_DmBleBroadcast: start = %d ", start);
1247 if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
1249 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
1251 p_msg->hdr.event = BTA_DM_API_BLE_BROADCAST_EVT;
1252 p_msg->start = start;
1254 bta_sys_sendmsg(p_msg);
1259 /*******************************************************************************
1261 ** Function BTA_DmBleSetBgConnType
1263 ** Description This function is called to set BLE connectable mode for a
1264 ** peripheral device.
1266 ** Parameters bg_conn_type: it can be auto connection, or selective connection.
1267 ** p_select_cback: callback function when selective connection procedure
1272 *******************************************************************************/
1273 void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_CBACK *p_select_cback)
1275 #if BLE_INCLUDED == TRUE
1276 tBTA_DM_API_BLE_SET_BG_CONN_TYPE *p_msg;
1278 if ((p_msg = (tBTA_DM_API_BLE_SET_BG_CONN_TYPE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE))) != NULL)
1280 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE));
1282 p_msg->hdr.event = BTA_DM_API_BLE_SET_BG_CONN_TYPE;
1283 p_msg->bg_conn_type = bg_conn_type;
1284 p_msg->p_select_cback = p_select_cback;
1286 bta_sys_sendmsg(p_msg);
1291 /*******************************************************************************
1293 ** Function bta_dm_discover_send_msg
1295 ** Description This function send discover message to BTA task.
1299 *******************************************************************************/
1300 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1301 static void bta_dm_discover_send_msg(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
1302 tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search,
1303 tBTA_TRANSPORT transport)
1305 tBTA_DM_API_DISCOVER *p_msg;
1306 UINT16 len = p_services ? (sizeof(tBTA_DM_API_DISCOVER) +
1307 sizeof(tBT_UUID) * p_services->num_uuid) :
1308 sizeof(tBTA_DM_API_DISCOVER);
1310 if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(len)) != NULL)
1312 memset(p_msg, 0, len);
1314 p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
1315 bdcpy(p_msg->bd_addr, bd_addr);
1316 p_msg->p_cback = p_cback;
1317 p_msg->sdp_search = sdp_search;
1318 p_msg->transport = transport;
1320 if (p_services != NULL)
1322 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1323 p_msg->services = p_services->srvc_mask;
1324 p_msg->num_uuid = p_services->num_uuid;
1325 if (p_services->num_uuid != 0)
1327 p_msg->p_uuid = (tBT_UUID *)(p_msg + 1);
1328 memcpy(p_msg->p_uuid, p_services->p_uuid, sizeof(tBT_UUID) * p_services->num_uuid);
1333 bta_sys_sendmsg(p_msg);
1337 /*******************************************************************************
1339 ** Function BTA_DmDiscoverByTransport
1341 ** Description This function does service discovery on particular transport
1342 ** for services of a
1343 ** peer device. When services.num_uuid is 0, it indicates all
1344 ** GATT based services are to be searched; otherwise a list of
1345 ** UUID of interested services should be provided through
1346 ** p_services->p_uuid.
1352 *******************************************************************************/
1353 void BTA_DmDiscoverByTransport(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
1354 tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search,
1355 tBTA_TRANSPORT transport)
1357 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1358 bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, transport);
1363 /*******************************************************************************
1365 ** Function BTA_DmDiscoverExt
1367 ** Description This function does service discovery for services of a
1368 ** peer device. When services.num_uuid is 0, it indicates all
1369 ** GATT based services are to be searched; other wise a list of
1370 ** UUID of interested services should be provided through
1371 ** p_services->p_uuid.
1377 *******************************************************************************/
1378 void BTA_DmDiscoverExt(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
1379 tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search)
1381 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1382 bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, BTA_TRANSPORT_UNKNOWN);
1387 /*******************************************************************************
1389 ** Function BTA_DmSearchExt
1391 ** Description This function searches for peer Bluetooth devices. It performs
1392 ** an inquiry and gets the remote name for devices. Service
1393 ** discovery is done if services is non zero
1395 ** Parameters p_dm_inq: inquiry conditions
1396 ** p_services: if service is not empty, service discovery will be done.
1397 ** for all GATT based service condition, put num_uuid, and
1398 ** p_uuid is the pointer to the list of UUID values.
1399 ** p_cback: callback functino when search is completed.
1405 *******************************************************************************/
1406 void BTA_DmSearchExt(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK_EXT *p_services, tBTA_DM_SEARCH_CBACK *p_cback)
1408 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1409 tBTA_DM_API_SEARCH *p_msg;
1410 UINT16 len = p_services ? (sizeof(tBTA_DM_API_SEARCH) + sizeof(tBT_UUID) * p_services->num_uuid) :
1411 sizeof(tBTA_DM_API_SEARCH);
1413 if ((p_msg = (tBTA_DM_API_SEARCH *) GKI_getbuf(len)) != NULL)
1415 memset(p_msg, 0, len);
1417 p_msg->hdr.event = BTA_DM_API_SEARCH_EVT;
1418 memcpy(&p_msg->inq_params, p_dm_inq, sizeof(tBTA_DM_INQ));
1419 p_msg->p_cback = p_cback;
1420 p_msg->rs_res = BTA_DM_RS_NONE;
1423 if (p_services != NULL)
1425 p_msg->services = p_services->srvc_mask;
1426 p_msg->num_uuid = p_services->num_uuid;
1428 if (p_services->num_uuid != 0)
1430 p_msg->p_uuid = (tBT_UUID *)(p_msg + 1);
1431 memcpy(p_msg->p_uuid, p_services->p_uuid, sizeof(tBT_UUID) * p_services->num_uuid);
1434 p_msg->p_uuid = NULL;
1437 bta_sys_sendmsg(p_msg);
1445 /*******************************************************************************
1447 ** Function BTA_DmBleUpdateConnectionParam
1449 ** Description Update connection parameters, can only be used when connection is up.
1451 ** Parameters: bd_addr - BD address of the peer
1452 ** min_int - minimum connection interval, [0x0004~ 0x4000]
1453 ** max_int - maximum connection interval, [0x0004~ 0x4000]
1454 ** latency - slave latency [0 ~ 500]
1455 ** timeout - supervision timeout [0x000a ~ 0xc80]
1459 *******************************************************************************/
1460 void BTA_DmBleUpdateConnectionParam(BD_ADDR bd_addr, UINT16 min_int,
1461 UINT16 max_int, UINT16 latency,
1464 #if BLE_INCLUDED == TRUE
1465 tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
1467 p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
1470 memset(p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
1472 p_msg->hdr.event = BTA_DM_API_UPDATE_CONN_PARAM_EVT;
1473 bdcpy(p_msg->bd_addr, bd_addr);
1474 p_msg->min_int = min_int;
1475 p_msg->max_int = max_int;
1476 p_msg->latency = latency;
1477 p_msg->timeout = timeout;
1479 bta_sys_sendmsg(p_msg);
1483 /*******************************************************************************
1485 ** Function BTA_DmBleConfigLocalPrivacy
1487 ** Description Enable/disable privacy on the local device
1489 ** Parameters: privacy_enable - enable/disabe privacy on remote device.
1493 *******************************************************************************/
1494 void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable)
1496 #if BLE_INCLUDED == TRUE && BLE_PRIVACY_SPT == TRUE
1497 tBTA_DM_API_LOCAL_PRIVACY *p_msg;
1499 if ((p_msg = (tBTA_DM_API_LOCAL_PRIVACY *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE_PRIVACY))) != NULL)
1501 memset (p_msg, 0, sizeof(tBTA_DM_API_LOCAL_PRIVACY));
1503 p_msg->hdr.event = BTA_DM_API_LOCAL_PRIVACY_EVT;
1504 p_msg->privacy_enable = privacy_enable;
1506 bta_sys_sendmsg(p_msg);
1509 UNUSED (privacy_enable);
1513 #if BLE_INCLUDED == TRUE
1514 /*******************************************************************************
1516 ** Function BTA_BleEnableAdvInstance
1518 ** Description This function enable a Multi-ADV instance with the specififed
1521 ** Parameters p_params: pointer to the adv parameter structure.
1522 ** p_cback: callback function associated to this adv instance.
1523 ** p_ref: reference data pointer to this adv instance.
1525 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1527 *******************************************************************************/
1528 void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
1529 tBTA_BLE_MULTI_ADV_CBACK *p_cback,
1532 tBTA_DM_API_BLE_MULTI_ADV_ENB *p_msg;
1533 UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB);
1535 APPL_TRACE_API ("BTA_BleEnableAdvInstance");
1537 if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_ENB *) GKI_getbuf(len)) != NULL)
1539 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB));
1541 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_ENB_EVT;
1542 p_msg->p_cback = (void *)p_cback;
1543 if (p_params != NULL)
1545 p_msg->p_params = (void *)(p_msg + 1);
1546 memcpy(p_msg->p_params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
1548 p_msg->p_ref = p_ref;
1550 bta_sys_sendmsg(p_msg);
1554 /*******************************************************************************
1556 ** Function BTA_BleUpdateAdvInstParam
1558 ** Description This function update a Multi-ADV instance with the specififed
1561 ** Parameters inst_id: Adv instance to update the parameter.
1562 ** p_params: pointer to the adv parameter structure.
1564 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1566 *******************************************************************************/
1567 void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
1569 tBTA_DM_API_BLE_MULTI_ADV_PARAM *p_msg;
1570 UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM);
1572 APPL_TRACE_API ("BTA_BleUpdateAdvInstParam");
1573 if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_PARAM *) GKI_getbuf(len)) != NULL)
1575 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM));
1576 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT;
1577 p_msg->inst_id = inst_id;
1578 p_msg->p_params = (void *)(p_msg + 1);
1579 memcpy(p_msg->p_params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
1581 bta_sys_sendmsg(p_msg);
1585 /*******************************************************************************
1587 ** Function BTA_BleCfgAdvInstData
1589 ** Description This function configure a Multi-ADV instance with the specififed
1590 ** adv data or scan response data.
1592 ** Parameter inst_id: Adv instance to configure the adv data or scan response.
1593 ** is_scan_rsp: is the data scan response or adv data.
1594 ** data_mask: adv data type as bit mask.
1595 ** p_data: pointer to the ADV data structure tBTA_BLE_ADV_DATA. This
1596 ** memory space can not be freed until BTA_BLE_MULTI_ADV_DATA_EVT
1597 ** is sent to application.
1599 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1601 *******************************************************************************/
1602 void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
1603 tBTA_BLE_AD_MASK data_mask,
1604 tBTA_BLE_ADV_DATA *p_data)
1606 tBTA_DM_API_BLE_MULTI_ADV_DATA *p_msg = GKI_getbuf(sizeof(*p_msg));
1609 memset(p_msg, 0, sizeof(*p_msg));
1610 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_DATA_EVT;
1611 p_msg->inst_id = inst_id;
1612 p_msg->is_scan_rsp = is_scan_rsp;
1613 p_msg->data_mask = data_mask;
1614 memcpy(&p_msg->data, p_data, sizeof(p_msg->data));
1615 bta_sys_sendmsg(p_msg);
1618 /*******************************************************************************
1620 ** Function BTA_BleDisableAdvInstance
1622 ** Description This function disable a Multi-ADV instance.
1624 ** Parameter inst_id: instance ID to disable.
1626 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1628 *******************************************************************************/
1629 void BTA_BleDisableAdvInstance (UINT8 inst_id)
1631 tBTA_DM_API_BLE_MULTI_ADV_DISABLE *p_msg;
1633 APPL_TRACE_API ("BTA_BleDisableAdvInstance: %d", inst_id);
1634 if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DISABLE *)
1635 GKI_getbuf(sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE))) != NULL)
1637 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE));
1638 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT;
1639 p_msg->inst_id = inst_id;
1640 bta_sys_sendmsg(p_msg);
1644 /*******************************************************************************
1646 ** Function BTA_DmBleCfgFilterCondition
1648 ** Description This function is called to configure the adv data payload filter
1651 ** Parameters action: to read/write/clear
1652 ** cond_type: filter condition type
1653 ** filt_index - Filter index
1654 ** p_cond: filter condition parameter
1655 ** p_cmpl_back - Command completed callback
1656 ** ref_value - Reference value
1660 *******************************************************************************/
1661 void BTA_DmBleCfgFilterCondition(tBTA_DM_BLE_SCAN_COND_OP action,
1662 tBTA_DM_BLE_PF_COND_TYPE cond_type,
1663 tBTA_DM_BLE_PF_FILT_INDEX filt_index,
1664 tBTA_DM_BLE_PF_COND_PARAM *p_cond,
1665 tBTA_DM_BLE_PF_CFG_CBACK *p_cmpl_cback,
1666 tBTA_DM_BLE_REF_VALUE ref_value)
1668 #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
1669 tBTA_DM_API_CFG_FILTER_COND *p_msg;
1670 APPL_TRACE_API ("BTA_DmBleCfgFilterCondition: %d, %d", action, cond_type);
1672 UINT16 len = sizeof(tBTA_DM_API_CFG_FILTER_COND) +
1673 sizeof(tBTA_DM_BLE_PF_COND_PARAM);
1680 case BTA_DM_BLE_PF_SRVC_DATA_PATTERN:
1681 case BTA_DM_BLE_PF_MANU_DATA:
1682 /* Length of pattern and pattern mask and other elements in */
1683 /* tBTA_DM_BLE_PF_MANU_COND */
1684 len += ((p_cond->manu_data.data_len) * 2) +
1685 sizeof(UINT16) + sizeof(UINT16) + sizeof(UINT8);
1688 case BTA_DM_BLE_PF_LOCAL_NAME:
1689 len += ((p_cond->local_name.data_len) + sizeof(UINT8));
1692 case BTM_BLE_PF_SRVC_UUID:
1693 case BTM_BLE_PF_SRVC_SOL_UUID:
1694 len += sizeof(tBLE_BD_ADDR) + sizeof(tBTA_DM_BLE_PF_COND_MASK);
1702 if ((p_msg = (tBTA_DM_API_CFG_FILTER_COND *) GKI_getbuf(len)) != NULL)
1704 memset (p_msg, 0, len);
1706 p_msg->hdr.event = BTA_DM_API_CFG_FILTER_COND_EVT;
1707 p_msg->action = action;
1708 p_msg->cond_type = cond_type;
1709 p_msg->filt_index = filt_index;
1710 p_msg->p_filt_cfg_cback = p_cmpl_cback;
1711 p_msg->ref_value = ref_value;
1714 p_msg->p_cond_param = (tBTA_DM_BLE_PF_COND_PARAM *)(p_msg + 1);
1715 memcpy(p_msg->p_cond_param, p_cond, sizeof(tBTA_DM_BLE_PF_COND_PARAM));
1717 p = (UINT8 *)(p_msg->p_cond_param + 1);
1719 if (cond_type == BTA_DM_BLE_PF_SRVC_DATA_PATTERN ||
1720 cond_type == BTA_DM_BLE_PF_MANU_DATA)
1722 p_msg->p_cond_param->manu_data.p_pattern = p;
1723 p_msg->p_cond_param->manu_data.data_len = p_cond->manu_data.data_len;
1724 memcpy(p_msg->p_cond_param->manu_data.p_pattern, p_cond->manu_data.p_pattern,
1725 p_cond->manu_data.data_len);
1726 p += p_cond->manu_data.data_len;
1728 if (cond_type == BTA_DM_BLE_PF_MANU_DATA)
1730 p_msg->p_cond_param->manu_data.company_id_mask =
1731 p_cond->manu_data.company_id_mask;
1732 if ( p_cond->manu_data.p_pattern_mask != NULL)
1734 p_msg->p_cond_param->manu_data.p_pattern_mask = p;
1735 memcpy(p_msg->p_cond_param->manu_data.p_pattern_mask,
1736 p_cond->manu_data.p_pattern_mask, p_cond->manu_data.data_len);
1740 else if (cond_type == BTA_DM_BLE_PF_LOCAL_NAME)
1742 p_msg->p_cond_param->local_name.p_data = p;
1743 p_msg->p_cond_param->local_name.data_len =
1744 p_cond->local_name.data_len;
1745 memcpy(p_msg->p_cond_param->local_name.p_data,
1746 p_cond->local_name.p_data, p_cond->local_name.data_len);
1748 else if ((cond_type == BTM_BLE_PF_SRVC_UUID
1749 || cond_type == BTM_BLE_PF_SRVC_SOL_UUID))
1751 if (p_cond->srvc_uuid.p_target_addr != NULL)
1753 p_msg->p_cond_param->srvc_uuid.p_target_addr = (tBLE_BD_ADDR *)(p);
1754 p_msg->p_cond_param->srvc_uuid.p_target_addr->type =
1755 p_cond->srvc_uuid.p_target_addr->type;
1756 memcpy(p_msg->p_cond_param->srvc_uuid.p_target_addr->bda,
1757 p_cond->srvc_uuid.p_target_addr->bda, BD_ADDR_LEN);
1758 p = (UINT8*)( p_msg->p_cond_param->srvc_uuid.p_target_addr + 1);
1760 if (p_cond->srvc_uuid.p_uuid_mask)
1762 p_msg->p_cond_param->srvc_uuid.p_uuid_mask = (tBTA_DM_BLE_PF_COND_MASK *)p;
1763 memcpy(p_msg->p_cond_param->srvc_uuid.p_uuid_mask,
1764 p_cond->srvc_uuid.p_uuid_mask, sizeof(tBTA_DM_BLE_PF_COND_MASK));
1769 bta_sys_sendmsg(p_msg);
1776 UNUSED(p_cmpl_cback);
1781 /*******************************************************************************
1783 ** Function BTA_DmBleScanFilterSetup
1785 ** Description This function is called to setup the adv data payload filter param
1787 ** Parameters p_target: enable the filter condition on a target device; if NULL
1788 ** filt_index - Filter index
1789 ** p_filt_params -Filter parameters
1790 ** ref_value - Reference value
1791 ** action - Add, delete or clear
1792 ** p_cmpl_back - Command completed callback
1796 *******************************************************************************/
1797 void BTA_DmBleScanFilterSetup(UINT8 action, tBTA_DM_BLE_PF_FILT_INDEX filt_index,
1798 tBTA_DM_BLE_PF_FILT_PARAMS *p_filt_params,
1799 tBLE_BD_ADDR *p_target,
1800 tBTA_DM_BLE_PF_PARAM_CBACK *p_cmpl_cback,
1801 tBTA_DM_BLE_REF_VALUE ref_value)
1803 #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
1804 tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *p_msg;
1805 APPL_TRACE_API ("BTA_DmBleScanFilterSetup: %d", action);
1807 UINT16 len = sizeof(tBTA_DM_API_SCAN_FILTER_PARAM_SETUP) + sizeof(tBLE_BD_ADDR);
1809 if ((p_msg = (tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *) GKI_getbuf(len)) != NULL)
1811 memset (p_msg, 0, len);
1813 p_msg->hdr.event = BTA_DM_API_SCAN_FILTER_SETUP_EVT;
1814 p_msg->action = action;
1815 p_msg->filt_index = filt_index;
1817 memcpy(&p_msg->filt_params, p_filt_params, sizeof(tBTA_DM_BLE_PF_FILT_PARAMS));
1818 p_msg->p_filt_param_cback = p_cmpl_cback;
1819 p_msg->ref_value = ref_value;
1823 p_msg->p_target = (tBLE_BD_ADDR *)(p_msg + 1);
1824 memcpy(p_msg->p_target, p_target, sizeof(tBLE_BD_ADDR));
1827 bta_sys_sendmsg(p_msg);
1832 UNUSED(p_filt_params);
1834 UNUSED(p_cmpl_cback);
1839 /*******************************************************************************
1841 ** Function BTA_DmBleGetEnergyInfo
1843 ** Description This function is called to obtain the energy info
1845 ** Parameters p_cmpl_cback - Command complete callback
1849 *******************************************************************************/
1850 void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK *p_cmpl_cback)
1852 tBTA_DM_API_ENERGY_INFO *p_msg;
1853 APPL_TRACE_API ("BTA_DmBleGetEnergyInfo");
1855 UINT16 len = sizeof(tBTA_DM_API_ENERGY_INFO) + sizeof(tBLE_BD_ADDR);
1857 if ((p_msg = (tBTA_DM_API_ENERGY_INFO *) GKI_getbuf(len)) != NULL)
1859 memset (p_msg, 0, len);
1860 p_msg->hdr.event = BTA_DM_API_BLE_ENERGY_INFO_EVT;
1861 p_msg->p_energy_info_cback = p_cmpl_cback;
1862 bta_sys_sendmsg(p_msg);
1866 /*******************************************************************************
1868 ** Function BTA_DmEnableScanFilter
1870 ** Description This function is called to enable the adv data payload filter
1872 ** Parameters action - enable or disable the APCF feature
1873 ** p_cmpl_cback - Command completed callback
1874 ** ref_value - Reference value
1878 *******************************************************************************/
1879 void BTA_DmEnableScanFilter(UINT8 action, tBTA_DM_BLE_PF_STATUS_CBACK *p_cmpl_cback,
1880 tBTA_DM_BLE_REF_VALUE ref_value)
1882 #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
1883 tBTA_DM_API_ENABLE_SCAN_FILTER *p_msg;
1884 APPL_TRACE_API ("BTA_DmEnableScanFilter: %d", action);
1886 UINT16 len = sizeof(tBTA_DM_API_ENABLE_SCAN_FILTER) + sizeof(tBLE_BD_ADDR);
1888 if ((p_msg = (tBTA_DM_API_ENABLE_SCAN_FILTER *) GKI_getbuf(len)) != NULL)
1890 memset (p_msg, 0, len);
1892 p_msg->hdr.event = BTA_DM_API_SCAN_FILTER_ENABLE_EVT;
1893 p_msg->action = action;
1894 p_msg->ref_value = ref_value;
1895 p_msg->p_filt_status_cback = p_cmpl_cback;
1897 bta_sys_sendmsg(p_msg);
1901 UNUSED(p_cmpl_cback);
1906 /*******************************************************************************
1908 ** Function BTA_DmBleUpdateConnectionParams
1910 ** Description Update connection parameters, can only be used when connection is up.
1912 ** Parameters: bd_addr - BD address of the peer
1913 ** min_int - minimum connection interval, [0x0004~ 0x4000]
1914 ** max_int - maximum connection interval, [0x0004~ 0x4000]
1915 ** latency - slave latency [0 ~ 500]
1916 ** timeout - supervision timeout [0x000a ~ 0xc80]
1920 *******************************************************************************/
1921 void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, UINT16 max_int,
1922 UINT16 latency, UINT16 timeout)
1924 tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
1926 if ((p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM))) != NULL)
1928 memset (p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
1930 p_msg->hdr.event = BTA_DM_API_UPDATE_CONN_PARAM_EVT;
1931 bdcpy(p_msg->bd_addr, bd_addr);
1932 p_msg->min_int = min_int;
1933 p_msg->max_int = max_int;
1934 p_msg->latency = latency;
1935 p_msg->timeout = timeout;
1937 bta_sys_sendmsg(p_msg);
1941 /*******************************************************************************
1943 ** Function BTA_DmBleSetDataLength
1945 ** Description This function is to set maximum LE data packet size
1950 *******************************************************************************/
1951 void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length)
1953 tBTA_DM_API_BLE_SET_DATA_LENGTH *p_msg;
1955 if ((p_msg = (tBTA_DM_API_BLE_SET_DATA_LENGTH *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SET_DATA_LENGTH)))
1958 bdcpy(p_msg->remote_bda, remote_device);
1959 p_msg->hdr.event = BTA_DM_API_SET_DATA_LENGTH_EVT;
1960 p_msg->tx_data_length = tx_data_length;
1962 bta_sys_sendmsg(p_msg);
1968 /*******************************************************************************
1970 ** Function BTA_DmSetEncryption
1972 ** Description This function is called to ensure that connection is
1973 ** encrypted. Should be called only on an open connection.
1974 ** Typically only needed for connections that first want to
1975 ** bring up unencrypted links, then later encrypt them.
1977 ** Parameters: bd_addr - Address of the peer device
1978 ** transport - transport of the link to be encruypted
1979 ** p_callback - Pointer to callback function to indicat the
1980 ** link encryption status
1981 ** sec_act - This is the security action to indicate
1982 ** what knid of BLE security level is required for
1983 ** the BLE link if the BLE is supported
1984 ** Note: This parameter is ignored for the BR/EDR link
1985 ** or the BLE is not supported
1989 *******************************************************************************/
1990 void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCRYPT_CBACK *p_callback,
1991 tBTA_DM_BLE_SEC_ACT sec_act)
1993 tBTA_DM_API_SET_ENCRYPTION *p_msg;
1995 APPL_TRACE_API("BTA_DmSetEncryption"); //todo
1996 if ((p_msg = (tBTA_DM_API_SET_ENCRYPTION *) GKI_getbuf(sizeof(tBTA_DM_API_SET_ENCRYPTION))) != NULL)
1998 memset(p_msg, 0, sizeof(tBTA_DM_API_SET_ENCRYPTION));
2000 p_msg->hdr.event = BTA_DM_API_SET_ENCRYPTION_EVT;
2002 memcpy(p_msg->bd_addr, bd_addr, BD_ADDR_LEN);
2003 p_msg->transport = transport;
2004 p_msg->p_callback = p_callback;
2005 p_msg->sec_act = sec_act;
2007 bta_sys_sendmsg(p_msg);
2011 /*******************************************************************************
2013 ** Function BTA_DmCloseACL
2015 ** Description This function force to close an ACL connection and remove the
2016 ** device from the security database list of known devices.
2018 ** Parameters: bd_addr - Address of the peer device
2019 ** remove_dev - remove device or not after link down
2023 *******************************************************************************/
2024 void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev, tBTA_TRANSPORT transport)
2026 tBTA_DM_API_REMOVE_ACL *p_msg;
2028 APPL_TRACE_API("BTA_DmCloseACL");
2030 if ((p_msg = (tBTA_DM_API_REMOVE_ACL *) GKI_getbuf(sizeof(tBTA_DM_API_REMOVE_ACL))) != NULL)
2032 memset(p_msg, 0, sizeof(tBTA_DM_API_REMOVE_ACL));
2034 p_msg->hdr.event = BTA_DM_API_REMOVE_ACL_EVT;
2036 memcpy(p_msg->bd_addr, bd_addr, BD_ADDR_LEN);
2037 p_msg->remove_dev = remove_dev;
2038 p_msg->transport = transport;
2040 bta_sys_sendmsg(p_msg);
2044 #if BLE_INCLUDED == TRUE
2045 /*******************************************************************************
2047 ** Function BTA_DmBleObserve
2049 ** Description This procedure keep the device listening for advertising
2050 ** events from a broadcast device.
2052 ** Parameters start: start or stop observe.
2059 *******************************************************************************/
2060 extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
2061 tBTA_DM_SEARCH_CBACK *p_results_cb)
2063 tBTA_DM_API_BLE_OBSERVE *p_msg;
2065 APPL_TRACE_API("BTA_DmBleObserve:start = %d ", start);
2067 if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
2069 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
2071 p_msg->hdr.event = BTA_DM_API_BLE_OBSERVE_EVT;
2072 p_msg->start = start;
2073 p_msg->duration = duration;
2074 p_msg->p_cback = p_results_cb;
2076 bta_sys_sendmsg(p_msg);
2080 /*******************************************************************************
2082 ** Function BTA_VendorInit
2084 ** Description This function initializes vendor specific
2088 *******************************************************************************/
2089 void BTA_VendorInit (void)
2091 APPL_TRACE_API("BTA_VendorInit");
2094 /*******************************************************************************
2096 ** Function BTA_VendorCleanup
2098 ** Description This function frees up Broadcom specific VS specific dynamic memory
2102 *******************************************************************************/
2103 void BTA_VendorCleanup (void)
2105 tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
2106 BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
2108 #if (BLE_INCLUDED == TRUE && BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE)
2109 if (cmn_ble_vsc_cb.max_filter > 0)
2111 btm_ble_adv_filter_cleanup();
2112 #if BLE_PRIVACY_SPT == TRUE
2113 btm_ble_resolving_list_cleanup ();
2117 if (cmn_ble_vsc_cb.tot_scan_results_strg > 0)
2118 btm_ble_batchscan_cleanup();
2121 if(cmn_ble_vsc_cb.adv_inst_max > 0)
2122 btm_ble_multi_adv_cleanup();