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 ******************************************************************************/
25 #include "bt_common.h"
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 *) osi_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 *) osi_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 *) osi_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 *) osi_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 *) osi_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 *) osi_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 *) osi_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 *) osi_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 *) osi_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 *) osi_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 *) osi_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 *) osi_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 *) osi_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 *) osi_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 /*******************************************************************************
452 ** Function BTA_DmLocalOob
454 ** Description This function retrieves the OOB data from local controller.
455 ** The result is reported by:
456 ** - bta_dm_co_loc_oob_ext() if device supports secure
458 ** - bta_dm_co_loc_oob() if device doesn't support SC
462 *******************************************************************************/
463 void BTA_DmLocalOob(void)
465 tBTA_DM_API_LOC_OOB *p_msg;
467 if ((p_msg = (tBTA_DM_API_LOC_OOB *) osi_getbuf(sizeof(tBTA_DM_API_LOC_OOB))) != NULL)
469 p_msg->hdr.event = BTA_DM_API_LOC_OOB_EVT;
470 bta_sys_sendmsg(p_msg);
474 /*******************************************************************************
476 ** Function BTA_DmConfirm
478 ** Description This function accepts or rejects the numerical value of the
479 ** Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT
483 *******************************************************************************/
484 void BTA_DmConfirm(BD_ADDR bd_addr, BOOLEAN accept)
486 tBTA_DM_API_CONFIRM *p_msg;
488 if ((p_msg = (tBTA_DM_API_CONFIRM *) osi_getbuf(sizeof(tBTA_DM_API_CONFIRM))) != NULL)
490 p_msg->hdr.event = BTA_DM_API_CONFIRM_EVT;
491 bdcpy(p_msg->bd_addr, bd_addr);
492 p_msg->accept = accept;
493 bta_sys_sendmsg(p_msg);
497 /*******************************************************************************
499 ** Function BTA_DmAddDevice
501 ** Description This function adds a device to the security database list of
507 *******************************************************************************/
508 void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key,
509 tBTA_SERVICE_MASK trusted_mask, BOOLEAN is_trusted,
510 UINT8 key_type, tBTA_IO_CAP io_cap, UINT8 pin_length)
513 tBTA_DM_API_ADD_DEVICE *p_msg;
515 if ((p_msg = (tBTA_DM_API_ADD_DEVICE *) osi_getbuf(sizeof(tBTA_DM_API_ADD_DEVICE))) != NULL)
517 memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_DEVICE));
519 p_msg->hdr.event = BTA_DM_API_ADD_DEVICE_EVT;
520 bdcpy(p_msg->bd_addr, bd_addr);
521 p_msg->tm = trusted_mask;
522 p_msg->is_trusted = is_trusted;
523 p_msg->io_cap = io_cap;
527 p_msg->link_key_known = TRUE;
528 p_msg->key_type = key_type;
529 memcpy(p_msg->link_key, link_key, LINK_KEY_LEN);
532 /* Load device class if specified */
535 p_msg->dc_known = TRUE;
536 memcpy (p_msg->dc, dev_class, DEV_CLASS_LEN);
539 memset (p_msg->bd_name, 0, BD_NAME_LEN + 1);
540 memset (p_msg->features, 0, sizeof (p_msg->features));
541 p_msg->pin_length = pin_length;
543 bta_sys_sendmsg(p_msg);
548 /*******************************************************************************
550 ** Function BTA_DmRemoveDevice
552 ** Description This function removes a device fromthe security database list of
553 ** peer device. It manages unpairing even while connected.
558 *******************************************************************************/
559 tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr)
561 tBTA_DM_API_REMOVE_DEVICE *p_msg;
563 if ((p_msg = (tBTA_DM_API_REMOVE_DEVICE *) osi_getbuf(sizeof(tBTA_DM_API_REMOVE_DEVICE))) != NULL)
565 memset (p_msg, 0, sizeof(tBTA_DM_API_REMOVE_DEVICE));
567 p_msg->hdr.event = BTA_DM_API_REMOVE_DEVICE_EVT;
568 bdcpy(p_msg->bd_addr, bd_addr);
569 bta_sys_sendmsg(p_msg);
579 /*******************************************************************************
581 ** Function BTA_GetEirService
583 ** Description This function is called to get BTA service mask from EIR.
585 ** Parameters p_eir - pointer of EIR significant part
586 ** p_services - return the BTA service mask
590 *******************************************************************************/
591 extern const UINT16 bta_service_id_to_uuid_lkup_tbl [];
592 void BTA_GetEirService( UINT8 *p_eir, tBTA_SERVICE_MASK *p_services )
595 UINT8 num_uuid, max_num_uuid = 32;
596 UINT8 uuid_list[32*LEN_UUID_16];
597 UINT16 *p_uuid16 = (UINT16 *)uuid_list;
598 tBTA_SERVICE_MASK mask;
600 BTM_GetEirUuidList( p_eir, LEN_UUID_16, &num_uuid, uuid_list, max_num_uuid);
601 for( xx = 0; xx < num_uuid; xx++ )
604 for( yy = 0; yy < BTA_MAX_SERVICE_ID; yy++ )
606 if( *(p_uuid16 + xx) == bta_service_id_to_uuid_lkup_tbl[yy] )
614 /* for HSP v1.2 only device */
615 if (*(p_uuid16 + xx) == UUID_SERVCLASS_HEADSET_HS)
616 *p_services |= BTA_HSP_SERVICE_MASK;
618 if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SOURCE)
619 *p_services |= BTA_HL_SERVICE_MASK;
621 if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SINK)
622 *p_services |= BTA_HL_SERVICE_MASK;
626 /*******************************************************************************
628 ** Function BTA_DmGetConnectionState
630 ** Description Returns whether the remote device is currently connected.
632 ** Returns 0 if the device is NOT connected.
634 *******************************************************************************/
635 UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr )
637 tBTA_DM_PEER_DEVICE * p_dev = bta_dm_find_peer_device(bd_addr);
638 return (p_dev && p_dev->conn_state == BTA_DM_CONNECTED);
642 /*******************************************************************************
643 ** Device Identification (DI) Server Functions
644 *******************************************************************************/
645 /*******************************************************************************
647 ** Function BTA_DmSetLocalDiRecord
649 ** Description This function adds a DI record to the local SDP database.
651 ** Returns BTA_SUCCESS if record set sucessfully, otherwise error code.
653 *******************************************************************************/
654 tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info,
657 tBTA_STATUS status = BTA_FAILURE;
659 if(bta_dm_di_cb.di_num < BTA_DI_NUM_MAX)
661 if(SDP_SetLocalDiRecord((tSDP_DI_RECORD *)p_device_info, p_handle) == SDP_SUCCESS)
663 if(!p_device_info->primary_record)
665 bta_dm_di_cb.di_handle[bta_dm_di_cb.di_num] = *p_handle;
666 bta_dm_di_cb.di_num ++;
669 bta_sys_add_uuid(UUID_SERVCLASS_PNP_INFORMATION);
670 status = BTA_SUCCESS;
677 /*******************************************************************************
679 ** Function bta_dmexecutecallback
681 ** Description This function will request BTA to execute a call back in the context of BTU task
682 ** This API was named in lower case because it is only intended
683 ** for the internal customers(like BTIF).
687 *******************************************************************************/
688 void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK* p_callback, void * p_param)
690 tBTA_DM_API_EXECUTE_CBACK *p_msg;
692 if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
694 p_msg->hdr.event = BTA_DM_API_EXECUTE_CBACK_EVT;
695 p_msg->p_param= p_param;
696 p_msg->p_exec_cback= p_callback;
697 bta_sys_sendmsg(p_msg);
701 /*******************************************************************************
703 ** Function BTA_DmAddBleKey
705 ** Description Add/modify LE device information. This function will be
706 ** normally called during host startup to restore all required
707 ** information stored in the NVRAM.
709 ** Parameters: bd_addr - BD address of the peer
710 ** p_le_key - LE key values.
711 ** key_type - LE SMP key type.
713 ** Returns BTA_SUCCESS if successful
714 ** BTA_FAIL if operation failed.
716 *******************************************************************************/
717 void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_TYPE key_type)
719 #if BLE_INCLUDED == TRUE
721 tBTA_DM_API_ADD_BLEKEY *p_msg;
723 if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) osi_getbuf(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL)
725 memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLEKEY));
727 p_msg->hdr.event = BTA_DM_API_ADD_BLEKEY_EVT;
728 p_msg->key_type = key_type;
729 bdcpy(p_msg->bd_addr, bd_addr);
730 memcpy(&p_msg->blekey, p_le_key, sizeof(tBTA_LE_KEY_VALUE));
732 bta_sys_sendmsg(p_msg);
738 /*******************************************************************************
740 ** Function BTA_DmAddBleDevice
742 ** Description Add a BLE device. This function will be normally called
743 ** during host startup to restore all required information
744 ** for a LE device stored in the NVRAM.
746 ** Parameters: bd_addr - BD address of the peer
747 ** dev_type - Remote device's device type.
748 ** addr_type - LE device address type.
752 *******************************************************************************/
753 void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TYPE dev_type)
755 #if BLE_INCLUDED == TRUE
756 tBTA_DM_API_ADD_BLE_DEVICE *p_msg;
758 if ((p_msg = (tBTA_DM_API_ADD_BLE_DEVICE *) osi_getbuf(sizeof(tBTA_DM_API_ADD_BLE_DEVICE))) != NULL)
760 memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLE_DEVICE));
762 p_msg->hdr.event = BTA_DM_API_ADD_BLEDEVICE_EVT;
763 bdcpy(p_msg->bd_addr, bd_addr);
764 p_msg->addr_type = addr_type;
765 p_msg->dev_type = dev_type;
767 bta_sys_sendmsg(p_msg);
771 /*******************************************************************************
773 ** Function BTA_DmBlePasskeyReply
775 ** Description Send BLE SMP passkey reply.
777 ** Parameters: bd_addr - BD address of the peer
778 ** accept - passkey entry sucessful or declined.
779 ** passkey - passkey value, must be a 6 digit number,
784 *******************************************************************************/
785 void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
787 #if BLE_INCLUDED == TRUE
788 tBTA_DM_API_PASSKEY_REPLY *p_msg;
790 if ((p_msg = (tBTA_DM_API_PASSKEY_REPLY *) osi_getbuf(sizeof(tBTA_DM_API_PASSKEY_REPLY))) != NULL)
792 memset(p_msg, 0, sizeof(tBTA_DM_API_PASSKEY_REPLY));
794 p_msg->hdr.event = BTA_DM_API_BLE_PASSKEY_REPLY_EVT;
795 bdcpy(p_msg->bd_addr, bd_addr);
796 p_msg->accept = accept;
800 p_msg->passkey = passkey;
802 bta_sys_sendmsg(p_msg);
806 /*******************************************************************************
808 ** Function BTA_DmBleConfirmReply
810 ** Description Send BLE SMP SC user confirmation reply.
812 ** Parameters: bd_addr - BD address of the peer
813 ** accept - numbers to compare are the same or different.
817 *******************************************************************************/
818 void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept)
820 #if BLE_INCLUDED == TRUE
821 tBTA_DM_API_CONFIRM *p_msg = (tBTA_DM_API_CONFIRM *)osi_getbuf(sizeof(tBTA_DM_API_CONFIRM));
824 memset(p_msg, 0, sizeof(tBTA_DM_API_CONFIRM));
825 p_msg->hdr.event = BTA_DM_API_BLE_CONFIRM_REPLY_EVT;
826 bdcpy(p_msg->bd_addr, bd_addr);
827 p_msg->accept = accept;
828 bta_sys_sendmsg(p_msg);
833 /*******************************************************************************
835 ** Function BTA_DmBleSecurityGrant
837 ** Description Grant security request access.
839 ** Parameters: bd_addr - BD address of the peer
840 ** res - security grant status.
844 *******************************************************************************/
845 void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res)
847 #if BLE_INCLUDED == TRUE
848 tBTA_DM_API_BLE_SEC_GRANT *p_msg;
850 if ((p_msg = (tBTA_DM_API_BLE_SEC_GRANT *) osi_getbuf(sizeof(tBTA_DM_API_BLE_SEC_GRANT))) != NULL)
852 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SEC_GRANT));
854 p_msg->hdr.event = BTA_DM_API_BLE_SEC_GRANT_EVT;
855 bdcpy(p_msg->bd_addr, bd_addr);
858 bta_sys_sendmsg(p_msg);
862 /*******************************************************************************
864 ** Function BTA_DmSetBlePrefConnParams
866 ** Description This function is called to set the preferred connection
867 ** parameters when default connection parameter is not desired.
869 ** Parameters: bd_addr - BD address of the peripheral
870 ** scan_interval - scan interval
871 ** scan_window - scan window
872 ** min_conn_int - minimum preferred connection interval
873 ** max_conn_int - maximum preferred connection interval
874 ** slave_latency - preferred slave latency
875 ** supervision_tout - preferred supervision timeout
880 *******************************************************************************/
881 void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr,
882 UINT16 min_conn_int, UINT16 max_conn_int,
883 UINT16 slave_latency, UINT16 supervision_tout )
885 #if BLE_INCLUDED == TRUE
886 tBTA_DM_API_BLE_CONN_PARAMS *p_msg;
888 if ((p_msg = (tBTA_DM_API_BLE_CONN_PARAMS *) osi_getbuf(sizeof(tBTA_DM_API_BLE_CONN_PARAMS))) != NULL)
890 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_CONN_PARAMS));
892 p_msg->hdr.event = BTA_DM_API_BLE_CONN_PARAM_EVT;
894 memcpy(p_msg->peer_bda, bd_addr, BD_ADDR_LEN);
896 p_msg->conn_int_max = max_conn_int;
897 p_msg->conn_int_min = min_conn_int;
898 p_msg->slave_latency = slave_latency;
899 p_msg->supervision_tout = supervision_tout;
901 bta_sys_sendmsg(p_msg);
906 /*******************************************************************************
908 ** Function BTA_DmSetBleConnScanParams
910 ** Description This function is called to set scan parameters used in
911 ** BLE connection request
913 ** Parameters: scan_interval - scan interval
914 ** scan_window - scan window
918 *******************************************************************************/
919 void BTA_DmSetBleConnScanParams(UINT32 scan_interval, UINT32 scan_window)
921 #if BLE_INCLUDED == TRUE
922 tBTA_DM_API_BLE_SCAN_PARAMS *p_msg;
923 if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)osi_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);
931 #endif // BLE_INCLUDED == TRUE
934 /*******************************************************************************
936 ** Function BTA_DmSetBleScanParams
938 ** Description This function is called to set scan parameters
940 ** Parameters: client_if - Client IF
941 ** scan_interval - scan interval
942 ** scan_window - scan window
943 ** scan_mode - scan mode
944 ** scan_param_setup_status_cback - Set scan param status callback
948 *******************************************************************************/
950 #if BLE_INCLUDED == TRUE
951 void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
952 UINT32 scan_window, tBLE_SCAN_MODE scan_mode,
953 tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback)
955 tBTA_DM_API_BLE_SCAN_PARAMS *p_msg;
957 if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)osi_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
959 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS));
960 p_msg->hdr.event = BTA_DM_API_BLE_SCAN_PARAM_EVT;
961 p_msg->client_if = client_if;
962 p_msg->scan_int = scan_interval;
963 p_msg->scan_window = scan_window;
964 p_msg->scan_mode = scan_mode;
965 p_msg->scan_param_setup_cback = scan_param_setup_cback;
967 bta_sys_sendmsg(p_msg);
970 #endif // BLE_INCLUDED == TRUE
972 /*******************************************************************************
974 ** Function BTA_DmSetBleAdvParams
976 ** Description This function sets the advertising parameters BLE functionality.
977 ** It is to be called when device act in peripheral or broadcaster
983 *******************************************************************************/
984 void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
985 tBLE_BD_ADDR *p_dir_bda)
987 #if BLE_INCLUDED == TRUE
988 tBTA_DM_API_BLE_ADV_PARAMS *p_msg;
990 APPL_TRACE_API ("BTA_DmSetBleAdvParam: %d, %d", adv_int_min, adv_int_max);
992 if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) osi_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS))) != NULL)
994 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS));
996 p_msg->hdr.event = BTA_DM_API_BLE_ADV_PARAM_EVT;
998 p_msg->adv_int_min = adv_int_min;
999 p_msg->adv_int_max = adv_int_max;
1001 if (p_dir_bda != NULL)
1003 p_msg->p_dir_bda = (tBLE_BD_ADDR *)(p_msg + 1);
1004 memcpy(p_msg->p_dir_bda, p_dir_bda, sizeof(tBLE_BD_ADDR));
1007 bta_sys_sendmsg(p_msg);
1011 /*******************************************************************************
1012 ** BLE ADV data management API
1013 ********************************************************************************/
1015 #if BLE_INCLUDED == TRUE
1016 /*******************************************************************************
1018 ** Function BTA_DmBleSetAdvConfig
1020 ** Description This function is called to override the BTA default ADV parameters.
1022 ** Parameters data_mask: adv data mask.
1023 ** p_adv_cfg: Pointer to User defined ADV data structure. This
1024 ** memory space can not be freed until p_adv_data_cback
1026 ** p_adv_data_cback: set adv data complete callback.
1030 *******************************************************************************/
1031 void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
1032 tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
1034 tBTA_DM_API_SET_ADV_CONFIG *p_msg = osi_getbuf(sizeof(*p_msg));
1037 memset(p_msg, 0, sizeof(*p_msg));
1038 p_msg->hdr.event = BTA_DM_API_BLE_SET_ADV_CONFIG_EVT;
1039 p_msg->data_mask = data_mask;
1040 p_msg->p_adv_data_cback = p_adv_data_cback;
1041 memcpy(&p_msg->adv_cfg, p_adv_cfg, sizeof(p_msg->adv_cfg));
1042 bta_sys_sendmsg(p_msg);
1045 /*******************************************************************************
1047 ** Function BTA_DmBleSetScanRsp
1049 ** Description This function is called to override the BTA scan response.
1051 ** Parameters Pointer to User defined ADV data structure
1055 *******************************************************************************/
1056 extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
1057 tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
1059 tBTA_DM_API_SET_ADV_CONFIG *p_msg = osi_getbuf(sizeof(*p_msg));
1062 memset(p_msg, 0, sizeof(*p_msg));
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 memcpy(&p_msg->adv_cfg, p_adv_cfg, sizeof(p_msg->adv_cfg));
1067 bta_sys_sendmsg(p_msg);
1070 /*******************************************************************************
1072 ** Function BTA_DmBleSetStorageParams
1074 ** Description This function is called to override the BTA scan response.
1076 ** Parameters batch_scan_full_max -Max storage space (in %) allocated to full scanning
1077 ** batch_scan_trunc_max -Max storage space (in %) allocated to truncated scanning
1078 ** batch_scan_notify_threshold -Setup notification level based on total space
1079 ** p_setup_cback - Setup callback pointer
1080 ** p_thres_cback - Threshold callback pointer
1081 ** p_rep_cback - Reports callback pointer
1082 ** ref_value - Ref value
1086 *******************************************************************************/
1087 extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max,
1088 UINT8 batch_scan_trunc_max,
1089 UINT8 batch_scan_notify_threshold,
1090 tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback,
1091 tBTA_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
1092 tBTA_BLE_SCAN_REP_CBACK* p_rep_cback,
1093 tBTA_DM_BLE_REF_VALUE ref_value)
1095 tBTA_DM_API_SET_STORAGE_CONFIG *p_msg;
1096 bta_dm_cb.p_setup_cback = p_setup_cback;
1097 if ((p_msg = (tBTA_DM_API_SET_STORAGE_CONFIG *)
1098 osi_getbuf(sizeof(tBTA_DM_API_SET_STORAGE_CONFIG))) != NULL)
1100 p_msg->hdr.event = BTA_DM_API_BLE_SETUP_STORAGE_EVT;
1101 p_msg->p_setup_cback=bta_ble_scan_setup_cb;
1102 p_msg->p_thres_cback=p_thres_cback;
1103 p_msg->p_read_rep_cback=p_rep_cback;
1104 p_msg->ref_value = ref_value;
1105 p_msg->batch_scan_full_max = batch_scan_full_max;
1106 p_msg->batch_scan_trunc_max = batch_scan_trunc_max;
1107 p_msg->batch_scan_notify_threshold = batch_scan_notify_threshold;
1108 bta_sys_sendmsg(p_msg);
1112 /*******************************************************************************
1114 ** Function BTA_DmBleEnableBatchScan
1116 ** Description This function is called to enable the batch scan
1118 ** Parameters scan_mode -Batch scan mode
1119 ** scan_interval - Scan interval
1120 ** scan_window - Scan window
1121 ** discard_rule -Discard rules
1122 ** addr_type - Address type
1123 ** ref_value - Reference value
1127 *******************************************************************************/
1128 extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode,
1129 UINT32 scan_interval, UINT32 scan_window,
1130 tBTA_BLE_DISCARD_RULE discard_rule,
1131 tBLE_ADDR_TYPE addr_type,
1132 tBTA_DM_BLE_REF_VALUE ref_value)
1134 tBTA_DM_API_ENABLE_SCAN *p_msg;
1136 if ((p_msg = (tBTA_DM_API_ENABLE_SCAN *) osi_getbuf(sizeof(tBTA_DM_API_ENABLE_SCAN))) != NULL)
1138 p_msg->hdr.event = BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT;
1139 p_msg->scan_mode = scan_mode;
1140 p_msg->scan_int = scan_interval;
1141 p_msg->scan_window = scan_window;
1142 p_msg->discard_rule = discard_rule;
1143 p_msg->addr_type = addr_type;
1144 p_msg->ref_value = ref_value;
1145 bta_sys_sendmsg(p_msg);
1149 /*******************************************************************************
1151 ** Function BTA_DmBleDisableBatchScan
1153 ** Description This function is called to disable the batch scan
1155 ** Parameters ref_value - Reference value
1159 *******************************************************************************/
1160 extern void BTA_DmBleDisableBatchScan(tBTA_DM_BLE_REF_VALUE ref_value)
1162 tBTA_DM_API_DISABLE_SCAN *p_msg;
1164 if ((p_msg = (tBTA_DM_API_DISABLE_SCAN *)
1165 osi_getbuf(sizeof(tBTA_DM_API_DISABLE_SCAN))) != NULL)
1167 p_msg->hdr.event = BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT;
1168 p_msg->ref_value = ref_value;
1169 bta_sys_sendmsg(p_msg);
1173 /*******************************************************************************
1175 ** Function BTA_DmBleReadScanReports
1177 ** Description This function is called to read scan reports
1179 ** Parameters scan_type -Batch scan mode
1180 ** ref_value - Reference value
1184 *******************************************************************************/
1185 extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type,
1186 tBTA_DM_BLE_REF_VALUE ref_value)
1188 tBTA_DM_API_READ_SCAN_REPORTS *p_msg;
1190 if ((p_msg = (tBTA_DM_API_READ_SCAN_REPORTS *)
1191 osi_getbuf(sizeof(tBTA_DM_API_READ_SCAN_REPORTS))) != NULL)
1193 p_msg->hdr.event = BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT;
1194 p_msg->scan_type = scan_type;
1195 p_msg->ref_value = ref_value;
1196 bta_sys_sendmsg(p_msg);
1200 /*******************************************************************************
1202 ** Function BTA_DmBleTrackAdvertiser
1204 ** Description This function is called to track advertiser
1206 ** Parameters ref_value - Reference value
1207 ** p_track_adv_cback - Track ADV callback
1211 *******************************************************************************/
1212 extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value,
1213 tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback)
1215 tBTA_DM_API_TRACK_ADVERTISER *p_msg;
1217 if ((p_msg = (tBTA_DM_API_TRACK_ADVERTISER *)
1218 osi_getbuf(sizeof(tBTA_DM_API_TRACK_ADVERTISER))) != NULL)
1220 p_msg->hdr.event = BTA_DM_API_BLE_TRACK_ADVERTISER_EVT;
1221 p_msg->p_track_adv_cback = p_track_adv_cback;
1222 p_msg->ref_value = ref_value;
1223 bta_sys_sendmsg(p_msg);
1229 /*******************************************************************************
1230 ** BLE ADV data management API
1231 ********************************************************************************/
1232 #if BLE_INCLUDED == TRUE
1234 /*******************************************************************************
1236 ** Function BTA_DmBleBroadcast
1238 ** Description This function starts or stops LE broadcasting.
1240 ** Parameters start: start or stop broadcast.
1244 *******************************************************************************/
1245 extern void BTA_DmBleBroadcast (BOOLEAN start)
1247 tBTA_DM_API_BLE_OBSERVE *p_msg;
1249 APPL_TRACE_API("BTA_DmBleBroadcast: start = %d ", start);
1251 if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) osi_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
1253 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
1255 p_msg->hdr.event = BTA_DM_API_BLE_BROADCAST_EVT;
1256 p_msg->start = start;
1258 bta_sys_sendmsg(p_msg);
1263 /*******************************************************************************
1265 ** Function BTA_DmBleSetBgConnType
1267 ** Description This function is called to set BLE connectable mode for a
1268 ** peripheral device.
1270 ** Parameters bg_conn_type: it can be auto connection, or selective connection.
1271 ** p_select_cback: callback function when selective connection procedure
1276 *******************************************************************************/
1277 void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_CBACK *p_select_cback)
1279 #if BLE_INCLUDED == TRUE
1280 tBTA_DM_API_BLE_SET_BG_CONN_TYPE *p_msg;
1282 if ((p_msg = (tBTA_DM_API_BLE_SET_BG_CONN_TYPE *) osi_getbuf(sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE))) != NULL)
1284 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE));
1286 p_msg->hdr.event = BTA_DM_API_BLE_SET_BG_CONN_TYPE;
1287 p_msg->bg_conn_type = bg_conn_type;
1288 p_msg->p_select_cback = p_select_cback;
1290 bta_sys_sendmsg(p_msg);
1295 /*******************************************************************************
1297 ** Function bta_dm_discover_send_msg
1299 ** Description This function send discover message to BTA task.
1303 *******************************************************************************/
1304 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1305 static void bta_dm_discover_send_msg(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
1306 tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search,
1307 tBTA_TRANSPORT transport)
1309 tBTA_DM_API_DISCOVER *p_msg;
1310 UINT16 len = p_services ? (sizeof(tBTA_DM_API_DISCOVER) +
1311 sizeof(tBT_UUID) * p_services->num_uuid) :
1312 sizeof(tBTA_DM_API_DISCOVER);
1314 if ((p_msg = (tBTA_DM_API_DISCOVER *) osi_getbuf(len)) != NULL)
1316 memset(p_msg, 0, len);
1318 p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
1319 bdcpy(p_msg->bd_addr, bd_addr);
1320 p_msg->p_cback = p_cback;
1321 p_msg->sdp_search = sdp_search;
1322 p_msg->transport = transport;
1324 if (p_services != NULL)
1326 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1327 p_msg->services = p_services->srvc_mask;
1328 p_msg->num_uuid = p_services->num_uuid;
1329 if (p_services->num_uuid != 0)
1331 p_msg->p_uuid = (tBT_UUID *)(p_msg + 1);
1332 memcpy(p_msg->p_uuid, p_services->p_uuid, sizeof(tBT_UUID) * p_services->num_uuid);
1337 bta_sys_sendmsg(p_msg);
1341 /*******************************************************************************
1343 ** Function BTA_DmDiscoverByTransport
1345 ** Description This function does service discovery on particular transport
1346 ** for services of a
1347 ** peer device. When services.num_uuid is 0, it indicates all
1348 ** GATT based services are to be searched; otherwise a list of
1349 ** UUID of interested services should be provided through
1350 ** p_services->p_uuid.
1356 *******************************************************************************/
1357 void BTA_DmDiscoverByTransport(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
1358 tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search,
1359 tBTA_TRANSPORT transport)
1361 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1362 bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, transport);
1367 /*******************************************************************************
1369 ** Function BTA_DmDiscoverExt
1371 ** Description This function does service discovery for services of a
1372 ** peer device. When services.num_uuid is 0, it indicates all
1373 ** GATT based services are to be searched; other wise a list of
1374 ** UUID of interested services should be provided through
1375 ** p_services->p_uuid.
1381 *******************************************************************************/
1382 void BTA_DmDiscoverExt(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
1383 tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search)
1385 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1386 bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, BTA_TRANSPORT_UNKNOWN);
1391 /*******************************************************************************
1393 ** Function BTA_DmSearchExt
1395 ** Description This function searches for peer Bluetooth devices. It performs
1396 ** an inquiry and gets the remote name for devices. Service
1397 ** discovery is done if services is non zero
1399 ** Parameters p_dm_inq: inquiry conditions
1400 ** p_services: if service is not empty, service discovery will be done.
1401 ** for all GATT based service condition, put num_uuid, and
1402 ** p_uuid is the pointer to the list of UUID values.
1403 ** p_cback: callback functino when search is completed.
1409 *******************************************************************************/
1410 void BTA_DmSearchExt(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK_EXT *p_services, tBTA_DM_SEARCH_CBACK *p_cback)
1412 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
1413 tBTA_DM_API_SEARCH *p_msg;
1414 UINT16 len = p_services ? (sizeof(tBTA_DM_API_SEARCH) + sizeof(tBT_UUID) * p_services->num_uuid) :
1415 sizeof(tBTA_DM_API_SEARCH);
1417 if ((p_msg = (tBTA_DM_API_SEARCH *) osi_getbuf(len)) != NULL)
1419 memset(p_msg, 0, len);
1421 p_msg->hdr.event = BTA_DM_API_SEARCH_EVT;
1422 memcpy(&p_msg->inq_params, p_dm_inq, sizeof(tBTA_DM_INQ));
1423 p_msg->p_cback = p_cback;
1424 p_msg->rs_res = BTA_DM_RS_NONE;
1427 if (p_services != NULL)
1429 p_msg->services = p_services->srvc_mask;
1430 p_msg->num_uuid = p_services->num_uuid;
1432 if (p_services->num_uuid != 0)
1434 p_msg->p_uuid = (tBT_UUID *)(p_msg + 1);
1435 memcpy(p_msg->p_uuid, p_services->p_uuid, sizeof(tBT_UUID) * p_services->num_uuid);
1438 p_msg->p_uuid = NULL;
1441 bta_sys_sendmsg(p_msg);
1449 /*******************************************************************************
1451 ** Function BTA_DmBleUpdateConnectionParam
1453 ** Description Update connection parameters, can only be used when connection is up.
1455 ** Parameters: bd_addr - BD address of the peer
1456 ** min_int - minimum connection interval, [0x0004~ 0x4000]
1457 ** max_int - maximum connection interval, [0x0004~ 0x4000]
1458 ** latency - slave latency [0 ~ 500]
1459 ** timeout - supervision timeout [0x000a ~ 0xc80]
1463 *******************************************************************************/
1464 void BTA_DmBleUpdateConnectionParam(BD_ADDR bd_addr, UINT16 min_int,
1465 UINT16 max_int, UINT16 latency,
1468 #if BLE_INCLUDED == TRUE
1469 tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
1471 p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) osi_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
1474 memset(p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
1476 p_msg->hdr.event = BTA_DM_API_UPDATE_CONN_PARAM_EVT;
1477 bdcpy(p_msg->bd_addr, bd_addr);
1478 p_msg->min_int = min_int;
1479 p_msg->max_int = max_int;
1480 p_msg->latency = latency;
1481 p_msg->timeout = timeout;
1483 bta_sys_sendmsg(p_msg);
1487 /*******************************************************************************
1489 ** Function BTA_DmBleConfigLocalPrivacy
1491 ** Description Enable/disable privacy on the local device
1493 ** Parameters: privacy_enable - enable/disabe privacy on remote device.
1497 *******************************************************************************/
1498 void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable)
1500 #if BLE_INCLUDED == TRUE && BLE_PRIVACY_SPT == TRUE
1501 tBTA_DM_API_LOCAL_PRIVACY *p_msg;
1503 if ((p_msg = (tBTA_DM_API_LOCAL_PRIVACY *) osi_getbuf(sizeof(tBTA_DM_API_ENABLE_PRIVACY))) != NULL)
1505 memset (p_msg, 0, sizeof(tBTA_DM_API_LOCAL_PRIVACY));
1507 p_msg->hdr.event = BTA_DM_API_LOCAL_PRIVACY_EVT;
1508 p_msg->privacy_enable = privacy_enable;
1510 bta_sys_sendmsg(p_msg);
1513 UNUSED (privacy_enable);
1517 #if BLE_INCLUDED == TRUE
1518 /*******************************************************************************
1520 ** Function BTA_BleEnableAdvInstance
1522 ** Description This function enable a Multi-ADV instance with the specififed
1525 ** Parameters p_params: pointer to the adv parameter structure.
1526 ** p_cback: callback function associated to this adv instance.
1527 ** p_ref: reference data pointer to this adv instance.
1529 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1531 *******************************************************************************/
1532 void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
1533 tBTA_BLE_MULTI_ADV_CBACK *p_cback,
1536 tBTA_DM_API_BLE_MULTI_ADV_ENB *p_msg;
1537 UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB);
1539 APPL_TRACE_API ("BTA_BleEnableAdvInstance");
1541 if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_ENB *) osi_getbuf(len)) != NULL)
1543 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB));
1545 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_ENB_EVT;
1546 p_msg->p_cback = (void *)p_cback;
1547 if (p_params != NULL)
1549 p_msg->p_params = (void *)(p_msg + 1);
1550 memcpy(p_msg->p_params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
1552 p_msg->p_ref = p_ref;
1554 bta_sys_sendmsg(p_msg);
1558 /*******************************************************************************
1560 ** Function BTA_BleUpdateAdvInstParam
1562 ** Description This function update a Multi-ADV instance with the specififed
1565 ** Parameters inst_id: Adv instance to update the parameter.
1566 ** p_params: pointer to the adv parameter structure.
1568 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1570 *******************************************************************************/
1571 void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
1573 tBTA_DM_API_BLE_MULTI_ADV_PARAM *p_msg;
1574 UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM);
1576 APPL_TRACE_API ("BTA_BleUpdateAdvInstParam");
1577 if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_PARAM *) osi_getbuf(len)) != NULL)
1579 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM));
1580 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT;
1581 p_msg->inst_id = inst_id;
1582 p_msg->p_params = (void *)(p_msg + 1);
1583 memcpy(p_msg->p_params, p_params, sizeof(tBTA_BLE_ADV_PARAMS));
1585 bta_sys_sendmsg(p_msg);
1589 /*******************************************************************************
1591 ** Function BTA_BleCfgAdvInstData
1593 ** Description This function configure a Multi-ADV instance with the specififed
1594 ** adv data or scan response data.
1596 ** Parameter inst_id: Adv instance to configure the adv data or scan response.
1597 ** is_scan_rsp: is the data scan response or adv data.
1598 ** data_mask: adv data type as bit mask.
1599 ** p_data: pointer to the ADV data structure tBTA_BLE_ADV_DATA. This
1600 ** memory space can not be freed until BTA_BLE_MULTI_ADV_DATA_EVT
1601 ** is sent to application.
1603 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1605 *******************************************************************************/
1606 void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
1607 tBTA_BLE_AD_MASK data_mask,
1608 tBTA_BLE_ADV_DATA *p_data)
1610 tBTA_DM_API_BLE_MULTI_ADV_DATA *p_msg = osi_getbuf(sizeof(*p_msg));
1613 memset(p_msg, 0, sizeof(*p_msg));
1614 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_DATA_EVT;
1615 p_msg->inst_id = inst_id;
1616 p_msg->is_scan_rsp = is_scan_rsp;
1617 p_msg->data_mask = data_mask;
1618 memcpy(&p_msg->data, p_data, sizeof(p_msg->data));
1619 bta_sys_sendmsg(p_msg);
1622 /*******************************************************************************
1624 ** Function BTA_BleDisableAdvInstance
1626 ** Description This function disable a Multi-ADV instance.
1628 ** Parameter inst_id: instance ID to disable.
1630 ** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
1632 *******************************************************************************/
1633 void BTA_BleDisableAdvInstance (UINT8 inst_id)
1635 tBTA_DM_API_BLE_MULTI_ADV_DISABLE *p_msg;
1637 APPL_TRACE_API ("BTA_BleDisableAdvInstance: %d", inst_id);
1638 if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DISABLE *)
1639 osi_getbuf(sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE))) != NULL)
1641 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE));
1642 p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT;
1643 p_msg->inst_id = inst_id;
1644 bta_sys_sendmsg(p_msg);
1648 /*******************************************************************************
1650 ** Function BTA_DmBleCfgFilterCondition
1652 ** Description This function is called to configure the adv data payload filter
1655 ** Parameters action: to read/write/clear
1656 ** cond_type: filter condition type
1657 ** filt_index - Filter index
1658 ** p_cond: filter condition parameter
1659 ** p_cmpl_back - Command completed callback
1660 ** ref_value - Reference value
1664 *******************************************************************************/
1665 void BTA_DmBleCfgFilterCondition(tBTA_DM_BLE_SCAN_COND_OP action,
1666 tBTA_DM_BLE_PF_COND_TYPE cond_type,
1667 tBTA_DM_BLE_PF_FILT_INDEX filt_index,
1668 tBTA_DM_BLE_PF_COND_PARAM *p_cond,
1669 tBTA_DM_BLE_PF_CFG_CBACK *p_cmpl_cback,
1670 tBTA_DM_BLE_REF_VALUE ref_value)
1672 #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
1673 tBTA_DM_API_CFG_FILTER_COND *p_msg;
1674 APPL_TRACE_API ("BTA_DmBleCfgFilterCondition: %d, %d", action, cond_type);
1676 UINT16 len = sizeof(tBTA_DM_API_CFG_FILTER_COND) +
1677 sizeof(tBTA_DM_BLE_PF_COND_PARAM);
1684 case BTA_DM_BLE_PF_SRVC_DATA_PATTERN:
1685 case BTA_DM_BLE_PF_MANU_DATA:
1686 /* Length of pattern and pattern mask and other elements in */
1687 /* tBTA_DM_BLE_PF_MANU_COND */
1688 len += ((p_cond->manu_data.data_len) * 2) +
1689 sizeof(UINT16) + sizeof(UINT16) + sizeof(UINT8);
1692 case BTA_DM_BLE_PF_LOCAL_NAME:
1693 len += ((p_cond->local_name.data_len) + sizeof(UINT8));
1696 case BTM_BLE_PF_SRVC_UUID:
1697 case BTM_BLE_PF_SRVC_SOL_UUID:
1698 len += sizeof(tBLE_BD_ADDR) + sizeof(tBTA_DM_BLE_PF_COND_MASK);
1706 if ((p_msg = (tBTA_DM_API_CFG_FILTER_COND *) osi_getbuf(len)) != NULL)
1708 memset (p_msg, 0, len);
1710 p_msg->hdr.event = BTA_DM_API_CFG_FILTER_COND_EVT;
1711 p_msg->action = action;
1712 p_msg->cond_type = cond_type;
1713 p_msg->filt_index = filt_index;
1714 p_msg->p_filt_cfg_cback = p_cmpl_cback;
1715 p_msg->ref_value = ref_value;
1718 p_msg->p_cond_param = (tBTA_DM_BLE_PF_COND_PARAM *)(p_msg + 1);
1719 memcpy(p_msg->p_cond_param, p_cond, sizeof(tBTA_DM_BLE_PF_COND_PARAM));
1721 p = (UINT8 *)(p_msg->p_cond_param + 1);
1723 if (cond_type == BTA_DM_BLE_PF_SRVC_DATA_PATTERN ||
1724 cond_type == BTA_DM_BLE_PF_MANU_DATA)
1726 p_msg->p_cond_param->manu_data.p_pattern = p;
1727 p_msg->p_cond_param->manu_data.data_len = p_cond->manu_data.data_len;
1728 memcpy(p_msg->p_cond_param->manu_data.p_pattern, p_cond->manu_data.p_pattern,
1729 p_cond->manu_data.data_len);
1730 p += p_cond->manu_data.data_len;
1732 if (cond_type == BTA_DM_BLE_PF_MANU_DATA)
1734 p_msg->p_cond_param->manu_data.company_id_mask =
1735 p_cond->manu_data.company_id_mask;
1736 if ( p_cond->manu_data.p_pattern_mask != NULL)
1738 p_msg->p_cond_param->manu_data.p_pattern_mask = p;
1739 memcpy(p_msg->p_cond_param->manu_data.p_pattern_mask,
1740 p_cond->manu_data.p_pattern_mask, p_cond->manu_data.data_len);
1744 else if (cond_type == BTA_DM_BLE_PF_LOCAL_NAME)
1746 p_msg->p_cond_param->local_name.p_data = p;
1747 p_msg->p_cond_param->local_name.data_len =
1748 p_cond->local_name.data_len;
1749 memcpy(p_msg->p_cond_param->local_name.p_data,
1750 p_cond->local_name.p_data, p_cond->local_name.data_len);
1752 else if ((cond_type == BTM_BLE_PF_SRVC_UUID
1753 || cond_type == BTM_BLE_PF_SRVC_SOL_UUID))
1755 if (p_cond->srvc_uuid.p_target_addr != NULL)
1757 p_msg->p_cond_param->srvc_uuid.p_target_addr = (tBLE_BD_ADDR *)(p);
1758 p_msg->p_cond_param->srvc_uuid.p_target_addr->type =
1759 p_cond->srvc_uuid.p_target_addr->type;
1760 memcpy(p_msg->p_cond_param->srvc_uuid.p_target_addr->bda,
1761 p_cond->srvc_uuid.p_target_addr->bda, BD_ADDR_LEN);
1762 p = (UINT8*)( p_msg->p_cond_param->srvc_uuid.p_target_addr + 1);
1764 if (p_cond->srvc_uuid.p_uuid_mask)
1766 p_msg->p_cond_param->srvc_uuid.p_uuid_mask = (tBTA_DM_BLE_PF_COND_MASK *)p;
1767 memcpy(p_msg->p_cond_param->srvc_uuid.p_uuid_mask,
1768 p_cond->srvc_uuid.p_uuid_mask, sizeof(tBTA_DM_BLE_PF_COND_MASK));
1773 bta_sys_sendmsg(p_msg);
1780 UNUSED(p_cmpl_cback);
1785 /*******************************************************************************
1787 ** Function BTA_DmBleScanFilterSetup
1789 ** Description This function is called to setup the adv data payload filter param
1791 ** Parameters p_target: enable the filter condition on a target device; if NULL
1792 ** filt_index - Filter index
1793 ** p_filt_params -Filter parameters
1794 ** ref_value - Reference value
1795 ** action - Add, delete or clear
1796 ** p_cmpl_back - Command completed callback
1800 *******************************************************************************/
1801 void BTA_DmBleScanFilterSetup(UINT8 action, tBTA_DM_BLE_PF_FILT_INDEX filt_index,
1802 tBTA_DM_BLE_PF_FILT_PARAMS *p_filt_params,
1803 tBLE_BD_ADDR *p_target,
1804 tBTA_DM_BLE_PF_PARAM_CBACK *p_cmpl_cback,
1805 tBTA_DM_BLE_REF_VALUE ref_value)
1807 #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
1808 tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *p_msg;
1809 APPL_TRACE_API ("BTA_DmBleScanFilterSetup: %d", action);
1811 UINT16 len = sizeof(tBTA_DM_API_SCAN_FILTER_PARAM_SETUP) + sizeof(tBLE_BD_ADDR);
1813 if ((p_msg = (tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *) osi_getbuf(len)) != NULL)
1815 memset (p_msg, 0, len);
1817 p_msg->hdr.event = BTA_DM_API_SCAN_FILTER_SETUP_EVT;
1818 p_msg->action = action;
1819 p_msg->filt_index = filt_index;
1821 memcpy(&p_msg->filt_params, p_filt_params, sizeof(tBTA_DM_BLE_PF_FILT_PARAMS));
1822 p_msg->p_filt_param_cback = p_cmpl_cback;
1823 p_msg->ref_value = ref_value;
1827 p_msg->p_target = (tBLE_BD_ADDR *)(p_msg + 1);
1828 memcpy(p_msg->p_target, p_target, sizeof(tBLE_BD_ADDR));
1831 bta_sys_sendmsg(p_msg);
1836 UNUSED(p_filt_params);
1838 UNUSED(p_cmpl_cback);
1843 /*******************************************************************************
1845 ** Function BTA_DmBleGetEnergyInfo
1847 ** Description This function is called to obtain the energy info
1849 ** Parameters p_cmpl_cback - Command complete callback
1853 *******************************************************************************/
1854 void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK *p_cmpl_cback)
1856 tBTA_DM_API_ENERGY_INFO *p_msg;
1857 APPL_TRACE_API ("BTA_DmBleGetEnergyInfo");
1859 UINT16 len = sizeof(tBTA_DM_API_ENERGY_INFO) + sizeof(tBLE_BD_ADDR);
1861 if ((p_msg = (tBTA_DM_API_ENERGY_INFO *) osi_getbuf(len)) != NULL)
1863 memset (p_msg, 0, len);
1864 p_msg->hdr.event = BTA_DM_API_BLE_ENERGY_INFO_EVT;
1865 p_msg->p_energy_info_cback = p_cmpl_cback;
1866 bta_sys_sendmsg(p_msg);
1870 /*******************************************************************************
1872 ** Function BTA_DmEnableScanFilter
1874 ** Description This function is called to enable the adv data payload filter
1876 ** Parameters action - enable or disable the APCF feature
1877 ** p_cmpl_cback - Command completed callback
1878 ** ref_value - Reference value
1882 *******************************************************************************/
1883 void BTA_DmEnableScanFilter(UINT8 action, tBTA_DM_BLE_PF_STATUS_CBACK *p_cmpl_cback,
1884 tBTA_DM_BLE_REF_VALUE ref_value)
1886 #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
1887 tBTA_DM_API_ENABLE_SCAN_FILTER *p_msg;
1888 APPL_TRACE_API ("BTA_DmEnableScanFilter: %d", action);
1890 UINT16 len = sizeof(tBTA_DM_API_ENABLE_SCAN_FILTER) + sizeof(tBLE_BD_ADDR);
1892 if ((p_msg = (tBTA_DM_API_ENABLE_SCAN_FILTER *) osi_getbuf(len)) != NULL)
1894 memset (p_msg, 0, len);
1896 p_msg->hdr.event = BTA_DM_API_SCAN_FILTER_ENABLE_EVT;
1897 p_msg->action = action;
1898 p_msg->ref_value = ref_value;
1899 p_msg->p_filt_status_cback = p_cmpl_cback;
1901 bta_sys_sendmsg(p_msg);
1905 UNUSED(p_cmpl_cback);
1910 /*******************************************************************************
1912 ** Function BTA_DmBleUpdateConnectionParams
1914 ** Description Update connection parameters, can only be used when connection is up.
1916 ** Parameters: bd_addr - BD address of the peer
1917 ** min_int - minimum connection interval, [0x0004~ 0x4000]
1918 ** max_int - maximum connection interval, [0x0004~ 0x4000]
1919 ** latency - slave latency [0 ~ 500]
1920 ** timeout - supervision timeout [0x000a ~ 0xc80]
1924 *******************************************************************************/
1925 void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, UINT16 max_int,
1926 UINT16 latency, UINT16 timeout)
1928 tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
1930 if ((p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) osi_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM))) != NULL)
1932 memset (p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
1934 p_msg->hdr.event = BTA_DM_API_UPDATE_CONN_PARAM_EVT;
1935 bdcpy(p_msg->bd_addr, bd_addr);
1936 p_msg->min_int = min_int;
1937 p_msg->max_int = max_int;
1938 p_msg->latency = latency;
1939 p_msg->timeout = timeout;
1941 bta_sys_sendmsg(p_msg);
1945 /*******************************************************************************
1947 ** Function BTA_DmBleSetDataLength
1949 ** Description This function is to set maximum LE data packet size
1954 *******************************************************************************/
1955 void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length)
1957 tBTA_DM_API_BLE_SET_DATA_LENGTH *p_msg;
1959 if ((p_msg = (tBTA_DM_API_BLE_SET_DATA_LENGTH *)osi_getbuf(sizeof(tBTA_DM_API_BLE_SET_DATA_LENGTH)))
1962 bdcpy(p_msg->remote_bda, remote_device);
1963 p_msg->hdr.event = BTA_DM_API_SET_DATA_LENGTH_EVT;
1964 p_msg->tx_data_length = tx_data_length;
1966 bta_sys_sendmsg(p_msg);
1972 /*******************************************************************************
1974 ** Function BTA_DmSetEncryption
1976 ** Description This function is called to ensure that connection is
1977 ** encrypted. Should be called only on an open connection.
1978 ** Typically only needed for connections that first want to
1979 ** bring up unencrypted links, then later encrypt them.
1981 ** Parameters: bd_addr - Address of the peer device
1982 ** transport - transport of the link to be encruypted
1983 ** p_callback - Pointer to callback function to indicat the
1984 ** link encryption status
1985 ** sec_act - This is the security action to indicate
1986 ** what knid of BLE security level is required for
1987 ** the BLE link if the BLE is supported
1988 ** Note: This parameter is ignored for the BR/EDR link
1989 ** or the BLE is not supported
1993 *******************************************************************************/
1994 void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCRYPT_CBACK *p_callback,
1995 tBTA_DM_BLE_SEC_ACT sec_act)
1997 tBTA_DM_API_SET_ENCRYPTION *p_msg;
1999 APPL_TRACE_API("BTA_DmSetEncryption"); //todo
2000 if ((p_msg = (tBTA_DM_API_SET_ENCRYPTION *) osi_getbuf(sizeof(tBTA_DM_API_SET_ENCRYPTION))) != NULL)
2002 memset(p_msg, 0, sizeof(tBTA_DM_API_SET_ENCRYPTION));
2004 p_msg->hdr.event = BTA_DM_API_SET_ENCRYPTION_EVT;
2006 memcpy(p_msg->bd_addr, bd_addr, BD_ADDR_LEN);
2007 p_msg->transport = transport;
2008 p_msg->p_callback = p_callback;
2009 p_msg->sec_act = sec_act;
2011 bta_sys_sendmsg(p_msg);
2015 /*******************************************************************************
2017 ** Function BTA_DmCloseACL
2019 ** Description This function force to close an ACL connection and remove the
2020 ** device from the security database list of known devices.
2022 ** Parameters: bd_addr - Address of the peer device
2023 ** remove_dev - remove device or not after link down
2027 *******************************************************************************/
2028 void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev, tBTA_TRANSPORT transport)
2030 tBTA_DM_API_REMOVE_ACL *p_msg;
2032 APPL_TRACE_API("BTA_DmCloseACL");
2034 if ((p_msg = (tBTA_DM_API_REMOVE_ACL *) osi_getbuf(sizeof(tBTA_DM_API_REMOVE_ACL))) != NULL)
2036 memset(p_msg, 0, sizeof(tBTA_DM_API_REMOVE_ACL));
2038 p_msg->hdr.event = BTA_DM_API_REMOVE_ACL_EVT;
2040 memcpy(p_msg->bd_addr, bd_addr, BD_ADDR_LEN);
2041 p_msg->remove_dev = remove_dev;
2042 p_msg->transport = transport;
2044 bta_sys_sendmsg(p_msg);
2048 #if BLE_INCLUDED == TRUE
2049 /*******************************************************************************
2051 ** Function BTA_DmBleObserve
2053 ** Description This procedure keep the device listening for advertising
2054 ** events from a broadcast device.
2056 ** Parameters start: start or stop observe.
2063 *******************************************************************************/
2064 extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
2065 tBTA_DM_SEARCH_CBACK *p_results_cb)
2067 tBTA_DM_API_BLE_OBSERVE *p_msg;
2069 APPL_TRACE_API("BTA_DmBleObserve:start = %d ", start);
2071 if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) osi_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
2073 memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
2075 p_msg->hdr.event = BTA_DM_API_BLE_OBSERVE_EVT;
2076 p_msg->start = start;
2077 p_msg->duration = duration;
2078 p_msg->p_cback = p_results_cb;
2080 bta_sys_sendmsg(p_msg);
2084 /*******************************************************************************
2086 ** Function BTA_VendorInit
2088 ** Description This function initializes vendor specific
2092 *******************************************************************************/
2093 void BTA_VendorInit (void)
2095 APPL_TRACE_API("BTA_VendorInit");
2098 /*******************************************************************************
2100 ** Function BTA_VendorCleanup
2102 ** Description This function frees up Broadcom specific VS specific dynamic memory
2106 *******************************************************************************/
2107 void BTA_VendorCleanup (void)
2109 tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
2110 BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb);
2112 #if (BLE_INCLUDED == TRUE && BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE)
2113 if (cmn_ble_vsc_cb.max_filter > 0)
2115 btm_ble_adv_filter_cleanup();
2116 #if BLE_PRIVACY_SPT == TRUE
2117 btm_ble_resolving_list_cleanup ();
2121 if (cmn_ble_vsc_cb.tot_scan_results_strg > 0)
2122 btm_ble_batchscan_cleanup();
2125 if(cmn_ble_vsc_cb.adv_inst_max > 0)
2126 btm_ble_multi_adv_cleanup();