• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 1999-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This file contains the Bluetooth Manager (BTM) API function external
22  *  definitions.
23  *
24  ******************************************************************************/
25 #ifndef BTM_API_H
26 #define BTM_API_H
27 
28 #include "bt_target.h"
29 #include "device/include/esco_parameters.h"
30 #include "hcidefs.h"
31 #include "sdp_api.h"
32 
33 #include "smp_api.h"
34 
35 #include "btm_api_types.h"
36 
37 /*****************************************************************************
38  *  DEVICE CONTROL and COMMON
39  ****************************************************************************/
40 
41 /*****************************************************************************
42  *  EXTERNAL FUNCTION DECLARATIONS
43  ****************************************************************************/
44 
45 /*****************************************************************************
46  *  DEVICE CONTROL and COMMON FUNCTIONS
47  ****************************************************************************/
48 
49 /*******************************************************************************
50  *
51  * Function         BTM_DeviceReset
52  *
53  * Description      This function is called to reset the controller.  The
54  *                  Callback function if provided is called when startup of the
55  *                  device has completed.
56  *
57  * Returns          void
58  *
59  ******************************************************************************/
60 extern void BTM_DeviceReset(tBTM_CMPL_CB* p_cb);
61 
62 /*******************************************************************************
63  *
64  * Function         BTM_IsDeviceUp
65  *
66  * Description      This function is called to check if the device is up.
67  *
68  * Returns          true if device is up, else false
69  *
70  ******************************************************************************/
71 extern bool BTM_IsDeviceUp(void);
72 
73 /*******************************************************************************
74  *
75  * Function         BTM_SetLocalDeviceName
76  *
77  * Description      This function is called to set the local device name.
78  *
79  * Returns          BTM_CMD_STARTED if successful, otherwise an error
80  *
81  ******************************************************************************/
82 extern tBTM_STATUS BTM_SetLocalDeviceName(char* p_name);
83 
84 /*******************************************************************************
85  *
86  * Function         BTM_SetDeviceClass
87  *
88  * Description      This function is called to set the local device class
89  *
90  * Returns          BTM_SUCCESS if successful, otherwise an error
91  *
92  ******************************************************************************/
93 extern tBTM_STATUS BTM_SetDeviceClass(DEV_CLASS dev_class);
94 
95 /*******************************************************************************
96  *
97  * Function         BTM_ReadLocalDeviceName
98  *
99  * Description      This function is called to read the local device name.
100  *
101  * Returns          status of the operation
102  *                  If success, BTM_SUCCESS is returned and p_name points stored
103  *                              local device name
104  *                  If BTM doesn't store local device name, BTM_NO_RESOURCES is
105  *                              is returned and p_name is set to NULL
106  *
107  ******************************************************************************/
108 extern tBTM_STATUS BTM_ReadLocalDeviceName(char** p_name);
109 
110 /*******************************************************************************
111  *
112  * Function         BTM_ReadLocalDeviceNameFromController
113  *
114  * Description      Get local device name from controller. Do not use cached
115  *                  name (used to get chip-id prior to btm reset complete).
116  *
117  * Returns          BTM_CMD_STARTED if successful, otherwise an error
118  *
119  ******************************************************************************/
120 extern tBTM_STATUS BTM_ReadLocalDeviceNameFromController(
121     tBTM_CMPL_CB* p_rln_cmpl_cback);
122 
123 /*******************************************************************************
124  *
125  * Function         BTM_ReadDeviceClass
126  *
127  * Description      This function is called to read the local device class
128  *
129  * Returns          pointer to the device class
130  *
131  ******************************************************************************/
132 extern uint8_t* BTM_ReadDeviceClass(void);
133 
134 /*******************************************************************************
135  *
136  * Function         BTM_ReadLocalFeatures
137  *
138  * Description      This function is called to read the local features
139  *
140  * Returns          pointer to the local features string
141  *
142  ******************************************************************************/
143 extern uint8_t* BTM_ReadLocalFeatures(void);
144 
145 /*******************************************************************************
146  *
147  * Function         BTM_RegisterForDeviceStatusNotif
148  *
149  * Description      This function is called to register for device status
150  *                  change notifications.
151  *
152  * Returns          pointer to previous caller's callback function or NULL if
153  *                  first registration.
154  *
155  ******************************************************************************/
156 extern tBTM_DEV_STATUS_CB* BTM_RegisterForDeviceStatusNotif(
157     tBTM_DEV_STATUS_CB* p_cb);
158 
159 /*******************************************************************************
160  *
161  * Function         BTM_RegisterForVSEvents
162  *
163  * Description      This function is called to register/deregister for vendor
164  *                  specific HCI events.
165  *
166  *                  If is_register=true, then the function will be registered;
167  *                  otherwise the function will be deregistered.
168  *
169  * Returns          BTM_SUCCESS if successful,
170  *                  BTM_BUSY if maximum number of callbacks have already been
171  *                           registered.
172  *
173  ******************************************************************************/
174 extern tBTM_STATUS BTM_RegisterForVSEvents(tBTM_VS_EVT_CB* p_cb,
175                                            bool is_register);
176 
177 /*******************************************************************************
178  *
179  * Function         BTM_VendorSpecificCommand
180  *
181  * Description      Send a vendor specific HCI command to the controller.
182  *
183  ******************************************************************************/
184 extern void BTM_VendorSpecificCommand(uint16_t opcode, uint8_t param_len,
185                                       uint8_t* p_param_buf,
186                                       tBTM_VSC_CMPL_CB* p_cb);
187 
188 /*******************************************************************************
189  *
190  * Function         BTM_AllocateSCN
191  *
192  * Description      Look through the Server Channel Numbers for a free one to be
193  *                  used with an RFCOMM connection.
194  *
195  * Returns          Allocated SCN number or 0 if none.
196  *
197  ******************************************************************************/
198 extern uint8_t BTM_AllocateSCN(void);
199 
200 /*******************************************************************************
201  *
202  * Function         BTM_TryAllocateSCN
203  *
204  * Description      Try to allocate a fixed server channel
205  *
206  * Returns          Returns true if server channel was available
207  *
208  ******************************************************************************/
209 extern bool BTM_TryAllocateSCN(uint8_t scn);
210 
211 /*******************************************************************************
212  *
213  * Function         BTM_FreeSCN
214  *
215  * Description      Free the specified SCN.
216  *
217  * Returns          true if successful, false if SCN is not in use or invalid
218  *
219  ******************************************************************************/
220 extern bool BTM_FreeSCN(uint8_t scn);
221 
222 /*******************************************************************************
223  *
224  * Function         BTM_SetTraceLevel
225  *
226  * Description      This function sets the trace level for BTM.  If called with
227  *                  a value of 0xFF, it simply returns the current trace level.
228  *
229  * Returns          The new or current trace level
230  *
231  ******************************************************************************/
232 extern uint8_t BTM_SetTraceLevel(uint8_t new_level);
233 
234 /*******************************************************************************
235  *
236  * Function         BTM_WritePageTimeout
237  *
238  * Description      Send HCI Wite Page Timeout.
239  *
240  ******************************************************************************/
241 extern void BTM_WritePageTimeout(uint16_t timeout);
242 
243 /*******************************************************************************
244  *
245  * Function         BTM_WriteVoiceSettings
246  *
247  * Description      Send HCI Write Voice Settings command.
248  *                  See hcidefs.h for settings bitmask values.
249  *
250  ******************************************************************************/
251 extern void BTM_WriteVoiceSettings(uint16_t settings);
252 
253 /*******************************************************************************
254  *
255  * Function         BTM_EnableTestMode
256  *
257  * Description      Send HCI the enable device under test command.
258  *
259  *                  Note: Controller can only be taken out of this mode by
260  *                      resetting the controller.
261  *
262  * Returns
263  *      BTM_SUCCESS         Command sent.
264  *      BTM_NO_RESOURCES    If out of resources to send the command.
265  *
266  *
267  ******************************************************************************/
268 extern tBTM_STATUS BTM_EnableTestMode(void);
269 
270 /*******************************************************************************
271  * DEVICE DISCOVERY FUNCTIONS - Inquiry, Remote Name, Discovery, Class of Device
272  ******************************************************************************/
273 
274 /*******************************************************************************
275  *
276  * Function         BTM_SetDiscoverability
277  *
278  * Description      This function is called to set the device into or out of
279  *                  discoverable mode. Discoverable mode means inquiry
280  *                  scans are enabled.  If a value of '0' is entered for window
281  *                  or interval, the default values are used.
282  *
283  * Returns          BTM_SUCCESS if successful
284  *                  BTM_BUSY if a setting of the filter is already in progress
285  *                  BTM_NO_RESOURCES if couldn't get a memory pool buffer
286  *                  BTM_ILLEGAL_VALUE if a bad parameter was detected
287  *                  BTM_WRONG_MODE if the device is not up.
288  *
289  ******************************************************************************/
290 extern tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode, uint16_t window,
291                                           uint16_t interval);
292 
293 /*******************************************************************************
294  *
295  * Function         BTM_ReadDiscoverability
296  *
297  * Description      This function is called to read the current discoverability
298  *                  mode of the device.
299  *
300  * Output Params:   p_window - current inquiry scan duration
301  *                  p_interval - current inquiry scan interval
302  *
303  * Returns          BTM_NON_DISCOVERABLE, BTM_LIMITED_DISCOVERABLE, or
304  *                  BTM_GENERAL_DISCOVERABLE
305  *
306  ******************************************************************************/
307 extern uint16_t BTM_ReadDiscoverability(uint16_t* p_window,
308                                         uint16_t* p_interval);
309 
310 /*******************************************************************************
311  *
312  * Function         BTM_SetPeriodicInquiryMode
313  *
314  * Description      This function is called to set the device periodic inquiry
315  *                  mode. If the duration is zero, the periodic inquiry mode is
316  *                  cancelled.
317  *
318  * Parameters:      p_inqparms - pointer to the inquiry information
319  *                      mode - GENERAL or LIMITED inquiry
320  *                      duration - length in 1.28 sec intervals (If '0', the
321  *                                 inquiry is CANCELLED)
322  *                      max_resps - maximum amount of devices to search for
323  *                                  before ending the inquiry
324  *                      filter_cond_type - BTM_CLR_INQUIRY_FILTER,
325  *                                         BTM_FILTER_COND_DEVICE_CLASS, or
326  *                                         BTM_FILTER_COND_BD_ADDR
327  *                      filter_cond - value for the filter (based on
328  *                                                          filter_cond_type)
329  *
330  *                  max_delay - maximum amount of time between successive
331  *                              inquiries
332  *                  min_delay - minimum amount of time between successive
333  *                              inquiries
334  *                  p_results_cb - callback returning pointer to results
335  *                              (tBTM_INQ_RESULTS)
336  *
337  * Returns          BTM_CMD_STARTED if successfully started
338  *                  BTM_ILLEGAL_VALUE if a bad parameter is detected
339  *                  BTM_NO_RESOURCES if could not allocate a message buffer
340  *                  BTM_SUCCESS - if cancelling the periodic inquiry
341  *                  BTM_BUSY - if an inquiry is already active
342  *                  BTM_WRONG_MODE if the device is not up.
343  *
344  ******************************************************************************/
345 extern tBTM_STATUS BTM_SetPeriodicInquiryMode(
346     tBTM_INQ_PARMS* p_inqparms, uint16_t max_delay, uint16_t min_delay,
347     tBTM_INQ_RESULTS_CB* p_results_cb);
348 
349 /*******************************************************************************
350  *
351  * Function         BTM_StartInquiry
352  *
353  * Description      This function is called to start an inquiry.
354  *
355  * Parameters:      p_inqparms - pointer to the inquiry information
356  *                      mode - GENERAL or LIMITED inquiry
357  *                      duration - length in 1.28 sec intervals (If '0', the
358  *                                 inquiry is CANCELLED)
359  *                      max_resps - maximum amount of devices to search for
360  *                                  before ending the inquiry
361  *                      filter_cond_type - BTM_CLR_INQUIRY_FILTER,
362  *                                         BTM_FILTER_COND_DEVICE_CLASS, or
363  *                                         BTM_FILTER_COND_BD_ADDR
364  *                      filter_cond - value for the filter (based on
365  *                                                          filter_cond_type)
366  *
367  *                  p_results_cb  - Pointer to the callback routine which gets
368  *                                called upon receipt of an inquiry result. If
369  *                                this field is NULL, the application is not
370  *                                notified.
371  *
372  *                  p_cmpl_cb   - Pointer to the callback routine which gets
373  *                                called upon completion.  If this field is
374  *                                NULL, the application is not notified when
375  *                                completed.
376  * Returns          tBTM_STATUS
377  *                  BTM_CMD_STARTED if successfully initiated
378  *                  BTM_BUSY if already in progress
379  *                  BTM_ILLEGAL_VALUE if parameter(s) are out of range
380  *                  BTM_NO_RESOURCES if could not allocate resources to start
381  *                                   the command
382  *                  BTM_WRONG_MODE if the device is not up.
383  *
384  ******************************************************************************/
385 extern tBTM_STATUS BTM_StartInquiry(tBTM_INQ_PARMS* p_inqparms,
386                                     tBTM_INQ_RESULTS_CB* p_results_cb,
387                                     tBTM_CMPL_CB* p_cmpl_cb);
388 
389 /*******************************************************************************
390  *
391  * Function         BTM_IsInquiryActive
392  *
393  * Description      Return a bit mask of the current inquiry state
394  *
395  * Returns          BTM_INQUIRY_INACTIVE if inactive (0)
396  *                  BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active
397  *                  BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
398  *                  BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active
399  *
400  ******************************************************************************/
401 extern uint16_t BTM_IsInquiryActive(void);
402 
403 /*******************************************************************************
404  *
405  * Function         BTM_CancelInquiry
406  *
407  * Description      This function cancels an inquiry if active
408  *
409  * Returns          BTM_SUCCESS if successful
410  *                  BTM_NO_RESOURCES if could not allocate a message buffer
411  *                  BTM_WRONG_MODE if the device is not up.
412  *
413  ******************************************************************************/
414 extern tBTM_STATUS BTM_CancelInquiry(void);
415 
416 /*******************************************************************************
417  *
418  * Function         BTM_CancelPeriodicInquiry
419  *
420  * Description      This function cancels a periodic inquiry
421  *
422  * Returns
423  *                  BTM_NO_RESOURCES if could not allocate a message buffer
424  *                  BTM_SUCCESS - if cancelling the periodic inquiry
425  *                  BTM_WRONG_MODE if the device is not up.
426  *
427  ******************************************************************************/
428 extern tBTM_STATUS BTM_CancelPeriodicInquiry(void);
429 
430 /*******************************************************************************
431  *
432  * Function         BTM_SetConnectability
433  *
434  * Description      This function is called to set the device into or out of
435  *                  connectable mode. Discoverable mode means page scans are
436  *                  enabled.
437  *
438  * Returns          BTM_SUCCESS if successful
439  *                  BTM_ILLEGAL_VALUE if a bad parameter is detected
440  *                  BTM_NO_RESOURCES if could not allocate a message buffer
441  *                  BTM_WRONG_MODE if the device is not up.
442  *
443  ******************************************************************************/
444 extern tBTM_STATUS BTM_SetConnectability(uint16_t page_mode, uint16_t window,
445                                          uint16_t interval);
446 
447 /*******************************************************************************
448  *
449  * Function         BTM_ReadConnectability
450  *
451  * Description      This function is called to read the current discoverability
452  *                  mode of the device.
453  * Output Params    p_window - current page scan duration
454  *                  p_interval - current time between page scans
455  *
456  * Returns          BTM_NON_CONNECTABLE or BTM_CONNECTABLE
457  *
458  ******************************************************************************/
459 extern uint16_t BTM_ReadConnectability(uint16_t* p_window,
460                                        uint16_t* p_interval);
461 
462 /*******************************************************************************
463  *
464  * Function         BTM_SetInquiryMode
465  *
466  * Description      This function is called to set standard, with RSSI
467  *                  mode or extended of the inquiry for local device.
468  *
469  * Input Params:    BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or
470  *                  BTM_INQ_RESULT_EXTENDED
471  *
472  * Returns          BTM_SUCCESS if successful
473  *                  BTM_NO_RESOURCES if couldn't get a memory pool buffer
474  *                  BTM_ILLEGAL_VALUE if a bad parameter was detected
475  *                  BTM_WRONG_MODE if the device is not up.
476  *
477  ******************************************************************************/
478 extern tBTM_STATUS BTM_SetInquiryMode(uint8_t mode);
479 
480 /*******************************************************************************
481  *
482  * Function         BTM_SetInquiryScanType
483  *
484  * Description      This function is called to set the iquiry scan-type to
485  *                  standard or interlaced.
486  *
487  * Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
488  *
489  * Returns          BTM_SUCCESS if successful
490  *                  BTM_MODE_UNSUPPORTED if not a 1.2 device
491  *                  BTM_WRONG_MODE if the device is not up.
492  *
493  ******************************************************************************/
494 extern tBTM_STATUS BTM_SetInquiryScanType(uint16_t scan_type);
495 
496 /*******************************************************************************
497  *
498  * Function         BTM_SetPageScanType
499  *
500  * Description      This function is called to set the page scan-type to
501  *                  standard or interlaced.
502  *
503  * Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
504  *
505  * Returns          BTM_SUCCESS if successful
506  *                  BTM_MODE_UNSUPPORTED if not a 1.2 device
507  *                  BTM_WRONG_MODE if the device is not up.
508  *
509  ******************************************************************************/
510 
511 extern tBTM_STATUS BTM_SetPageScanType(uint16_t scan_type);
512 
513 /*******************************************************************************
514  *
515  * Function         BTM_ReadRemoteDeviceName
516  *
517  * Description      This function initiates a remote device HCI command to the
518  *                  controller and calls the callback when the process has
519  *                  completed.
520  *
521  * Input Params:    remote_bda      - device address of name to retrieve
522  *                  p_cb            - callback function called when
523  *                                    BTM_CMD_STARTED is returned.
524  *                                    A pointer to tBTM_REMOTE_DEV_NAME is
525  *                                    passed to the callback.
526  *
527  * Returns
528  *                  BTM_CMD_STARTED is returned if the request was successfully
529  *                                  sent to HCI.
530  *                  BTM_BUSY if already in progress
531  *                  BTM_UNKNOWN_ADDR if device address is bad
532  *                  BTM_NO_RESOURCES if resources could not be allocated to
533  *                                   start the command
534  *                  BTM_WRONG_MODE if the device is not up.
535  *
536  ******************************************************************************/
537 extern tBTM_STATUS BTM_ReadRemoteDeviceName(BD_ADDR remote_bda,
538                                             tBTM_CMPL_CB* p_cb,
539                                             tBT_TRANSPORT transport);
540 
541 /*******************************************************************************
542  *
543  * Function         BTM_CancelRemoteDeviceName
544  *
545  * Description      This function initiates the cancel request for the specified
546  *                  remote device.
547  *
548  * Input Params:    None
549  *
550  * Returns
551  *                  BTM_CMD_STARTED is returned if the request was successfully
552  *                                  sent to HCI.
553  *                  BTM_NO_RESOURCES if resources could not be allocated to
554  *                                   start the command
555  *                  BTM_WRONG_MODE if there is no active remote name request.
556  *
557  ******************************************************************************/
558 extern tBTM_STATUS BTM_CancelRemoteDeviceName(void);
559 
560 /*******************************************************************************
561  *
562  * Function         BTM_ReadRemoteVersion
563  *
564  * Description      This function is called to read a remote device's version
565  *
566  * Returns          BTM_SUCCESS if successful, otherwise an error
567  *
568  ******************************************************************************/
569 extern tBTM_STATUS BTM_ReadRemoteVersion(BD_ADDR addr, uint8_t* lmp_version,
570                                          uint16_t* manufacturer,
571                                          uint16_t* lmp_sub_version);
572 
573 /*******************************************************************************
574  *
575  * Function         BTM_ReadRemoteFeatures
576  *
577  * Description      This function is called to read a remote device's
578  *                  supported features mask (features mask located at page 0)
579  *
580  *                  Note: The size of device features mask page is
581  *                  BTM_FEATURE_BYTES_PER_PAGE bytes.
582  *
583  * Returns          pointer to the remote supported features mask
584  *
585  ******************************************************************************/
586 extern uint8_t* BTM_ReadRemoteFeatures(BD_ADDR addr);
587 
588 /*******************************************************************************
589  *
590  * Function         BTM_ReadRemoteExtendedFeatures
591  *
592  * Description      This function is called to read a specific extended features
593  *                  page of the remote device
594  *
595  *                  Note1: The size of device features mask page is
596  *                  BTM_FEATURE_BYTES_PER_PAGE bytes.
597  *                  Note2: The valid device features mask page number depends on
598  *                  the remote device capabilities. It is expected to be in the
599  *                  range [0 - BTM_EXT_FEATURES_PAGE_MAX].
600 
601  * Returns          pointer to the remote extended features mask
602  *                  or NULL if page_number is not valid
603  *
604  ******************************************************************************/
605 extern uint8_t* BTM_ReadRemoteExtendedFeatures(BD_ADDR addr,
606                                                uint8_t page_number);
607 
608 /*******************************************************************************
609  *
610  * Function         BTM_ReadNumberRemoteFeaturesPages
611  *
612  * Description      This function is called to retrieve the number of feature
613  *                  pages read from the remote device
614  *
615  * Returns          number of features pages read from the remote device
616  *
617  ******************************************************************************/
618 extern uint8_t BTM_ReadNumberRemoteFeaturesPages(BD_ADDR addr);
619 
620 /*******************************************************************************
621  *
622  * Function         BTM_ReadAllRemoteFeatures
623  *
624  * Description      Read all the features of the remote device
625  *
626  * Returns          pointer to the byte[0] of the page[0] of the remote device
627  *                  feature mask.
628  *
629  * Note:            the function returns the pointer to the array of the size
630  *                  BTM_FEATURE_BYTES_PER_PAGE * (BTM_EXT_FEATURES_PAGE_MAX + 1)
631  *
632  ******************************************************************************/
633 extern uint8_t* BTM_ReadAllRemoteFeatures(BD_ADDR addr);
634 
635 /*******************************************************************************
636  *
637  * Function         BTM_InqDbRead
638  *
639  * Description      This function looks through the inquiry database for a match
640  *                  based on Bluetooth Device Address. This is the application's
641  *                  interface to get the inquiry details of a specific BD
642  *                  address.
643  *
644  * Returns          pointer to entry, or NULL if not found
645  *
646  ******************************************************************************/
647 extern tBTM_INQ_INFO* BTM_InqDbRead(const BD_ADDR p_bda);
648 
649 /*******************************************************************************
650  *
651  * Function         BTM_InqDbFirst
652  *
653  * Description      This function looks through the inquiry database for the
654  *                  first used entry, and returns that. This is used in
655  *                  conjunction with BTM_InqDbNext by applications as a way to
656  *                  walk through the inquiry database.
657  *
658  * Returns          pointer to first in-use entry, or NULL if DB is empty
659  *
660  ******************************************************************************/
661 extern tBTM_INQ_INFO* BTM_InqDbFirst(void);
662 
663 /*******************************************************************************
664  *
665  * Function         BTM_InqDbNext
666  *
667  * Description      This function looks through the inquiry database for the
668  *                  next used entry, and returns that.  If the input parameter
669  *                  is NULL, the first entry is returned.
670  *
671  * Returns          pointer to next in-use entry, or NULL if no more found.
672  *
673  ******************************************************************************/
674 extern tBTM_INQ_INFO* BTM_InqDbNext(tBTM_INQ_INFO* p_cur);
675 
676 /*******************************************************************************
677  *
678  * Function         BTM_ClearInqDb
679  *
680  * Description      This function is called to clear out a device or all devices
681  *                  from the inquiry database.
682  *
683  * Parameter        p_bda - (input) BD_ADDR ->  Address of device to clear
684  *                                              (NULL clears all entries)
685  *
686  * Returns          BTM_BUSY if an inquiry, get remote name, or event filter
687  *                          is active, otherwise BTM_SUCCESS
688  *
689  ******************************************************************************/
690 extern tBTM_STATUS BTM_ClearInqDb(BD_ADDR p_bda);
691 
692 /*******************************************************************************
693  *
694  * Function         BTM_ReadInquiryRspTxPower
695  *
696  * Description      This command will read the inquiry Transmit Power level used
697  *                  to transmit the FHS and EIR data packets.
698  *                  This can be used directly in the Tx Power Level EIR data
699  *                  type.
700  *
701  * Returns          BTM_SUCCESS if successful
702  *
703  ******************************************************************************/
704 extern tBTM_STATUS BTM_ReadInquiryRspTxPower(tBTM_CMPL_CB* p_cb);
705 
706 /*******************************************************************************
707  *
708  * Function         BTM_StartDiscovery
709  *
710  * Description      This function is called by an application (or profile)
711  *                  when it wants to trigger an service discovery using the
712  *                  BTM's discovery database.
713  *
714  * Returns          tBTM_STATUS
715  *                      BTM_CMD_STARTED if the discovery was initiated
716  *                      BTM_BUSY if one is already in progress
717  *                      BTM_UNKNOWN_ADDR if no addresses are in the INQ DB
718  *                      BTM_ERR_PROCESSING if err initiating the command
719  *
720  ******************************************************************************/
721 extern tBTM_STATUS BTM_StartDiscovery(tBTM_CMPL_CB* p_cmpl_cb,
722                                       BD_ADDR_PTR p_rem_addr);
723 
724 /*******************************************************************************
725  *
726  * Function         BTM_FindAttribute
727  *
728  * Description      This function is called by an application (or profile)
729  *                  when it wants to see if an attribute exists in the BTM
730  *                  discovery database.
731  *
732  * Returns          Pointer to matching record, or NULL
733  *
734  ******************************************************************************/
735 extern tSDP_DISC_REC* BTM_FindAttribute(uint16_t attr_id,
736                                         tSDP_DISC_REC* p_start_rec);
737 
738 /*******************************************************************************
739  *
740  * Function         BTM_FindService
741  *
742  * Description      This function is called by an application (or profile)
743  *                  when it wants to see if a service exists in the BTM
744  *                  discovery database.
745  *
746  * Returns          Pointer to matching record, or NULL
747  *
748  ******************************************************************************/
749 extern tSDP_DISC_REC* BTM_FindService(uint16_t service_uuid,
750                                       tSDP_DISC_REC* p_start_rec);
751 
752 /*******************************************************************************
753  *
754  * Function         BTM_SetDiscoveryParams
755  *
756  * Description      This function is called to set the BTM default discovery
757  *                  parameters. These UUID and attribute filters are used during
758  *                  the call to BTM_StartDiscovery.
759  *
760  * Returns          void
761  *
762  ******************************************************************************/
763 extern void BTM_SetDiscoveryParams(uint16_t num_uuid, tSDP_UUID* p_uuid_list,
764                                    uint16_t num_attr, uint16_t* p_attr_list);
765 
766 /*****************************************************************************
767  *  ACL CHANNEL MANAGEMENT FUNCTIONS
768  ****************************************************************************/
769 /*******************************************************************************
770  *
771  * Function         BTM_SetLinkPolicy
772  *
773  * Description      Create and send HCI "Write Policy Set" command
774  *
775  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
776  *
777  ******************************************************************************/
778 extern tBTM_STATUS BTM_SetLinkPolicy(BD_ADDR remote_bda, uint16_t* settings);
779 
780 /*******************************************************************************
781  *
782  * Function         BTM_SetDefaultLinkPolicy
783  *
784  * Description      Set the default value for HCI "Write Policy Set" command
785  *                  to use when an ACL link is created.
786  *
787  * Returns          void
788  *
789  ******************************************************************************/
790 extern void BTM_SetDefaultLinkPolicy(uint16_t settings);
791 
792 /*******************************************************************************
793  *
794  * Function         BTM_SetDefaultLinkSuperTout
795  *
796  * Description      Set the default value for HCI "Write Link Supervision
797  *                  Timeout" command to use when an ACL link is created.
798  *
799  * Returns          void
800  *
801  ******************************************************************************/
802 extern void BTM_SetDefaultLinkSuperTout(uint16_t timeout);
803 
804 /*******************************************************************************
805  *
806  * Function         BTM_SetLinkSuperTout
807  *
808  * Description      Create and send HCI "Write Link Supervision Timeout" command
809  *
810  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
811  *
812  ******************************************************************************/
813 extern tBTM_STATUS BTM_SetLinkSuperTout(BD_ADDR remote_bda, uint16_t timeout);
814 /*******************************************************************************
815  *
816  * Function         BTM_GetLinkSuperTout
817  *
818  * Description      Read the link supervision timeout value of the connection
819  *
820  * Returns          status of the operation
821  *
822  ******************************************************************************/
823 extern tBTM_STATUS BTM_GetLinkSuperTout(BD_ADDR remote_bda,
824                                         uint16_t* p_timeout);
825 
826 /*******************************************************************************
827  *
828  * Function         BTM_IsAclConnectionUp
829  *
830  * Description      This function is called to check if an ACL connection exists
831  *                  to a specific remote BD Address.
832  *
833  * Returns          true if connection is up, else false.
834  *
835  ******************************************************************************/
836 extern bool BTM_IsAclConnectionUp(BD_ADDR remote_bda, tBT_TRANSPORT transport);
837 
838 /*******************************************************************************
839  *
840  * Function         BTM_GetRole
841  *
842  * Description      This function is called to get the role of the local device
843  *                  for the ACL connection with the specified remote device
844  *
845  * Returns          BTM_SUCCESS if connection exists.
846  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
847  *
848  ******************************************************************************/
849 extern tBTM_STATUS BTM_GetRole(BD_ADDR remote_bd_addr, uint8_t* p_role);
850 
851 /*******************************************************************************
852  *
853  * Function         BTM_SwitchRole
854  *
855  * Description      This function is called to switch role between master and
856  *                  slave.  If role is already set it will do nothing.  If the
857  *                  command was initiated, the callback function is called upon
858  *                  completion.
859  *
860  * Returns          BTM_SUCCESS if already in specified role.
861  *                  BTM_CMD_STARTED if command issued to controller.
862  *                  BTM_NO_RESOURCES if memory couldn't be allocated to issue
863  *                                   the command
864  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
865  *                  BTM_MODE_UNSUPPORTED if the local device does not support
866  *                                       role switching
867  *
868  ******************************************************************************/
869 extern tBTM_STATUS BTM_SwitchRole(BD_ADDR remote_bd_addr, uint8_t new_role,
870                                   tBTM_CMPL_CB* p_cb);
871 
872 /*******************************************************************************
873  *
874  * Function         BTM_ReadRSSI
875  *
876  * Description      This function is called to read the link policy settings.
877  *                  The address of link policy results are returned in the
878  *                  callback. (tBTM_RSSI_RESULTS)
879  *
880  * Returns          BTM_CMD_STARTED if command issued to controller.
881  *                  BTM_NO_RESOURCES if memory couldn't be allocated to issue
882  *                                   the command
883  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
884  *                  BTM_BUSY if command is already in progress
885  *
886  ******************************************************************************/
887 extern tBTM_STATUS BTM_ReadRSSI(const BD_ADDR remote_bda, tBTM_CMPL_CB* p_cb);
888 
889 /*******************************************************************************
890  *
891  * Function         BTM_ReadTxPower
892  *
893  * Description      This function is called to read the current connection
894  *                  TX power of the connection. The TX power level results
895  *                  are returned in the callback.
896  *                  (tBTM_RSSI_RESULTS)
897  *
898  * Returns          BTM_CMD_STARTED if command issued to controller.
899  *                  BTM_NO_RESOURCES if memory couldn't be allocated to issue
900  *                                   the command
901  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
902  *                  BTM_BUSY if command is already in progress
903  *
904  ******************************************************************************/
905 extern tBTM_STATUS BTM_ReadTxPower(BD_ADDR remote_bda, tBT_TRANSPORT transport,
906                                    tBTM_CMPL_CB* p_cb);
907 
908 /*******************************************************************************
909  *
910  * Function         BTM_ReadLinkQuality
911  *
912  * Description      This function is called to read the link quality.
913  *                  The value of the link quality is returned in the callback.
914  *                  (tBTM_LINK_QUALITY_RESULTS)
915  *
916  * Returns          BTM_CMD_STARTED if command issued to controller.
917  *                  BTM_NO_RESOURCES if memory couldn't be allocated to issue
918  *                                   the command
919  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
920  *                  BTM_BUSY if command is already in progress
921  *
922  ******************************************************************************/
923 extern tBTM_STATUS BTM_ReadLinkQuality(BD_ADDR remote_bda, tBTM_CMPL_CB* p_cb);
924 
925 /*******************************************************************************
926  *
927  * Function         BTM_RegBusyLevelNotif
928  *
929  * Description      This function is called to register a callback to receive
930  *                  busy level change events.
931  *
932  * Returns          BTM_SUCCESS if successfully registered, otherwise error
933  *
934  ******************************************************************************/
935 extern tBTM_STATUS BTM_RegBusyLevelNotif(tBTM_BL_CHANGE_CB* p_cb,
936                                          uint8_t* p_level,
937                                          tBTM_BL_EVENT_MASK evt_mask);
938 
939 /*******************************************************************************
940  *
941  * Function         BTM_AclRegisterForChanges
942  *
943  * Description      This function is called to register a callback to receive
944  *                  ACL database change events, i.e. new connection or removed.
945  *
946  * Returns          BTM_SUCCESS if successfully initiated, otherwise error
947  *
948  ******************************************************************************/
949 extern tBTM_STATUS BTM_AclRegisterForChanges(tBTM_ACL_DB_CHANGE_CB* p_cb);
950 
951 /*******************************************************************************
952  *
953  * Function         BTM_GetNumAclLinks
954  *
955  * Description      This function is called to count the number of
956  *                  ACL links that are active.
957  *
958  * Returns          uint16_t Number of active ACL links
959  *
960  ******************************************************************************/
961 extern uint16_t BTM_GetNumAclLinks(void);
962 
963 /*******************************************************************************
964  *
965  * Function         BTM_SetQoS
966  *
967  * Description      This function is called to setup QoS
968  *
969  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
970  *
971  ******************************************************************************/
972 extern tBTM_STATUS BTM_SetQoS(BD_ADDR bd, FLOW_SPEC* p_flow,
973                               tBTM_CMPL_CB* p_cb);
974 
975 /*****************************************************************************
976  *  (e)SCO CHANNEL MANAGEMENT FUNCTIONS
977  ****************************************************************************/
978 /*******************************************************************************
979  *
980  * Function         BTM_CreateSco
981  *
982  * Description      This function is called to create an SCO connection. If the
983  *                  "is_orig" flag is true, the connection will be originated,
984  *                  otherwise BTM will wait for the other side to connect.
985  *
986  * Returns          BTM_UNKNOWN_ADDR if the ACL connection is not up
987  *                  BTM_BUSY         if another SCO being set up to
988  *                                   the same BD address
989  *                  BTM_NO_RESOURCES if the max SCO limit has been reached
990  *                  BTM_CMD_STARTED  if the connection establishment is started.
991  *                                   In this case, "*p_sco_inx" is filled in
992  *                                   with the sco index used for the connection.
993  *
994  ******************************************************************************/
995 extern tBTM_STATUS BTM_CreateSco(BD_ADDR remote_bda, bool is_orig,
996                                  uint16_t pkt_types, uint16_t* p_sco_inx,
997                                  tBTM_SCO_CB* p_conn_cb,
998                                  tBTM_SCO_CB* p_disc_cb);
999 
1000 /*******************************************************************************
1001  *
1002  * Function         BTM_RemoveSco
1003  *
1004  * Description      This function is called to remove a specific SCO connection.
1005  *
1006  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
1007  *
1008  ******************************************************************************/
1009 extern tBTM_STATUS BTM_RemoveSco(uint16_t sco_inx);
1010 
1011 /*******************************************************************************
1012  *
1013  * Function         BTM_SetScoPacketTypes
1014  *
1015  * Description      This function is called to set the packet types used for
1016  *                  a specific SCO connection,
1017  *
1018  * Parameters       pkt_types - One or more of the following
1019  *                  BTM_SCO_PKT_TYPES_MASK_HV1
1020  *                  BTM_SCO_PKT_TYPES_MASK_HV2
1021  *                  BTM_SCO_PKT_TYPES_MASK_HV3
1022  *                  BTM_SCO_PKT_TYPES_MASK_EV3
1023  *                  BTM_SCO_PKT_TYPES_MASK_EV4
1024  *                  BTM_SCO_PKT_TYPES_MASK_EV5
1025  *
1026  *                  BTM_SCO_LINK_ALL_MASK   - enables all supported types
1027  *
1028  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
1029  *
1030  ******************************************************************************/
1031 extern tBTM_STATUS BTM_SetScoPacketTypes(uint16_t sco_inx, uint16_t pkt_types);
1032 
1033 /*******************************************************************************
1034  *
1035  * Function         BTM_ReadScoPacketTypes
1036  *
1037  * Description      This function is read the packet types used for a specific
1038  *                  SCO connection.
1039  *
1040  * Returns       One or more of the following (bitmask)
1041  *                  BTM_SCO_PKT_TYPES_MASK_HV1
1042  *                  BTM_SCO_PKT_TYPES_MASK_HV2
1043  *                  BTM_SCO_PKT_TYPES_MASK_HV3
1044  *                  BTM_SCO_PKT_TYPES_MASK_EV3
1045  *                  BTM_SCO_PKT_TYPES_MASK_EV4
1046  *                  BTM_SCO_PKT_TYPES_MASK_EV5
1047  *
1048  * Returns          packet types supported for the connection
1049  *
1050  ******************************************************************************/
1051 extern uint16_t BTM_ReadScoPacketTypes(uint16_t sco_inx);
1052 
1053 /*******************************************************************************
1054  *
1055  * Function         BTM_ReadDeviceScoPacketTypes
1056  *
1057  * Description      This function is read the SCO packet types that
1058  *                  the device supports.
1059  *
1060  * Returns          packet types supported by the device.
1061  *
1062  ******************************************************************************/
1063 extern uint16_t BTM_ReadDeviceScoPacketTypes(void);
1064 
1065 /*******************************************************************************
1066  *
1067  * Function         BTM_ReadScoHandle
1068  *
1069  * Description      Reead the HCI handle used for a specific SCO connection,
1070  *
1071  * Returns          handle for the connection, or 0xFFFF if invalid SCO index.
1072  *
1073  ******************************************************************************/
1074 extern uint16_t BTM_ReadScoHandle(uint16_t sco_inx);
1075 
1076 /*******************************************************************************
1077  *
1078  * Function         BTM_ReadScoBdAddr
1079  *
1080  * Description      This function is read the remote BD Address for a specific
1081  *                  SCO connection,
1082  *
1083  * Returns          pointer to BD address or NULL if not known
1084  *
1085  ******************************************************************************/
1086 extern uint8_t* BTM_ReadScoBdAddr(uint16_t sco_inx);
1087 
1088 /*******************************************************************************
1089  *
1090  * Function         BTM_ReadScoDiscReason
1091  *
1092  * Description      This function is returns the reason why an (e)SCO connection
1093  *                  has been removed. It contains the value until read, or until
1094  *                  another (e)SCO connection has disconnected.
1095  *
1096  * Returns          HCI reason or BTM_INVALID_SCO_DISC_REASON if not set.
1097  *
1098  ******************************************************************************/
1099 extern uint16_t BTM_ReadScoDiscReason(void);
1100 
1101 /*******************************************************************************
1102  *
1103  * Function         BTM_SetEScoMode
1104  *
1105  * Description      This function sets up the negotiated parameters for SCO or
1106  *                  eSCO, and sets as the default mode used for calls to
1107  *                  BTM_CreateSco.  It can be called only when there are no
1108  *                  active (e)SCO links.
1109  *
1110  * Returns          BTM_SUCCESS if the successful.
1111  *                  BTM_BUSY if there are one or more active (e)SCO links.
1112  *
1113  ******************************************************************************/
1114 extern tBTM_STATUS BTM_SetEScoMode(enh_esco_params_t* p_parms);
1115 
1116 /*******************************************************************************
1117  *
1118  * Function         BTM_SetWBSCodec
1119  *
1120  * Description      This function sends command to the controller to setup
1121  *                  WBS codec for the upcoming eSCO connection.
1122  *
1123  * Returns          BTM_SUCCESS.
1124  *
1125  *
1126  ******************************************************************************/
1127 extern tBTM_STATUS BTM_SetWBSCodec(tBTM_SCO_CODEC_TYPE codec_type);
1128 
1129 /*******************************************************************************
1130  *
1131  * Function         BTM_RegForEScoEvts
1132  *
1133  * Description      This function registers a SCO event callback with the
1134  *                  specified instance.  It should be used to received
1135  *                  connection indication events and change of link parameter
1136  *                  events.
1137  *
1138  * Returns          BTM_SUCCESS if the successful.
1139  *                  BTM_ILLEGAL_VALUE if there is an illegal sco_inx
1140  *
1141  ******************************************************************************/
1142 extern tBTM_STATUS BTM_RegForEScoEvts(uint16_t sco_inx,
1143                                       tBTM_ESCO_CBACK* p_esco_cback);
1144 
1145 /*******************************************************************************
1146  *
1147  * Function         BTM_ReadEScoLinkParms
1148  *
1149  * Description      This function returns the current eSCO link parameters for
1150  *                  the specified handle.  This can be called anytime a
1151  *                  connection is active, but is typically called after
1152  *                  receiving the SCO opened callback.
1153  *
1154  *                  Note: If called over a 1.1 controller, only the packet types
1155  *                        field has meaning.
1156  *                  Note: If the upper layer doesn't know the current sco index,
1157  *                  BTM_FIRST_ACTIVE_SCO_INDEX can be used as the first
1158  *                  parameter to find the first active SCO index
1159  *
1160  * Returns          BTM_SUCCESS if returned data is valid connection.
1161  *                  BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
1162  *                  BTM_MODE_UNSUPPORTED if local controller does not support
1163  *                      1.2 specification.
1164  *
1165  ******************************************************************************/
1166 extern tBTM_STATUS BTM_ReadEScoLinkParms(uint16_t sco_inx,
1167                                          tBTM_ESCO_DATA* p_parms);
1168 
1169 /*******************************************************************************
1170  *
1171  * Function         BTM_ChangeEScoLinkParms
1172  *
1173  * Description      This function requests renegotiation of the parameters on
1174  *                  the current eSCO Link.  If any of the changes are accepted
1175  *                  by the controllers, the BTM_ESCO_CHG_EVT event is sent in
1176  *                  the tBTM_ESCO_CBACK function with the current settings of
1177  *                  the link. The callback is registered through the call to
1178  *                  BTM_SetEScoMode.
1179  *
1180  *
1181  * Returns          BTM_CMD_STARTED if command is successfully initiated.
1182  *                  BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
1183  *                  BTM_NO_RESOURCES - not enough resources to initiate command.
1184  *                  BTM_MODE_UNSUPPORTED if local controller does not support
1185  *                      1.2 specification.
1186  *
1187  ******************************************************************************/
1188 extern tBTM_STATUS BTM_ChangeEScoLinkParms(uint16_t sco_inx,
1189                                            tBTM_CHG_ESCO_PARAMS* p_parms);
1190 
1191 /*******************************************************************************
1192  *
1193  * Function         BTM_EScoConnRsp
1194  *
1195  * Description      This function is called upon receipt of an (e)SCO connection
1196  *                  request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject
1197  *                  the request. Parameters used to negotiate eSCO links.
1198  *                  If p_parms is NULL, then values set through BTM_SetEScoMode
1199  *                  are used.
1200  *                  If the link type of the incoming request is SCO, then only
1201  *                  the tx_bw, max_latency, content format, and packet_types are
1202  *                  valid.  The hci_status parameter should be
1203  *                  ([0x0] to accept, [0x0d..0x0f] to reject)
1204  *
1205  *
1206  * Returns          void
1207  *
1208  ******************************************************************************/
1209 extern void BTM_EScoConnRsp(uint16_t sco_inx, uint8_t hci_status,
1210                             enh_esco_params_t* p_parms);
1211 
1212 /*******************************************************************************
1213  *
1214  * Function         BTM_GetNumScoLinks
1215  *
1216  * Description      This function returns the number of active SCO links.
1217  *
1218  * Returns          uint8_t
1219  *
1220  ******************************************************************************/
1221 extern uint8_t BTM_GetNumScoLinks(void);
1222 
1223 /*****************************************************************************
1224  *  SECURITY MANAGEMENT FUNCTIONS
1225  ****************************************************************************/
1226 /*******************************************************************************
1227  *
1228  * Function         BTM_SecRegister
1229  *
1230  * Description      Application manager calls this function to register for
1231  *                  security services.  There can be one and only one
1232  *                  application saving link keys.  BTM allows only first
1233  *                  registration.
1234  *
1235  * Returns          true if registered OK, else false
1236  *
1237  ******************************************************************************/
1238 extern bool BTM_SecRegister(tBTM_APPL_INFO* p_cb_info);
1239 
1240 /*******************************************************************************
1241  *
1242  * Function         BTM_SecRegisterLinkKeyNotificationCallback
1243  *
1244  * Description      Profiles can register to be notified when a new Link Key
1245  *                  is generated per connection.
1246  *
1247  * Returns          true if registered OK, else false
1248  *
1249  ******************************************************************************/
1250 extern bool BTM_SecRegisterLinkKeyNotificationCallback(
1251     tBTM_LINK_KEY_CALLBACK* p_callback);
1252 
1253 /*******************************************************************************
1254  *
1255  * Function         BTM_SecAddRmtNameNotifyCallback
1256  *
1257  * Description      Profiles can register to be notified when name of the
1258  *                  remote device is resolved (up to
1259  *                  BTM_SEC_MAX_RMT_NAME_CALLBACKS).
1260  *
1261  * Returns          true if registered OK, else false
1262  *
1263  ******************************************************************************/
1264 extern bool BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback);
1265 
1266 /*******************************************************************************
1267  *
1268  * Function         BTM_SecDeleteRmtNameNotifyCallback
1269  *
1270  * Description      A profile can deregister notification when a new Link Key
1271  *                  is generated per connection.
1272  *
1273  * Returns          true if OK, else false
1274  *
1275  ******************************************************************************/
1276 extern bool BTM_SecDeleteRmtNameNotifyCallback(
1277     tBTM_RMT_NAME_CALLBACK* p_callback);
1278 
1279 /*******************************************************************************
1280  *
1281  * Function         BTM_GetSecurityFlags
1282  *
1283  * Description      Get security flags for the device
1284  *
1285  * Returns          bool    true or false is device found
1286  *
1287  ******************************************************************************/
1288 extern bool BTM_GetSecurityFlags(BD_ADDR bd_addr, uint8_t* p_sec_flags);
1289 
1290 /*******************************************************************************
1291  *
1292  * Function         BTM_GetSecurityFlagsByTransport
1293  *
1294  * Description      Get security flags for the device on a particular transport
1295  *
1296  * Parameters      bd_addr: BD address of remote device
1297  *                  p_sec_flags : Out parameter to be filled with security
1298  *                                flags for the connection
1299  *                  transport :  Physical transport of the connection
1300  *                               (BR/EDR or LE)
1301  *
1302  * Returns          bool    true or false is device found
1303  *
1304  ******************************************************************************/
1305 extern bool BTM_GetSecurityFlagsByTransport(BD_ADDR bd_addr,
1306                                             uint8_t* p_sec_flags,
1307                                             tBT_TRANSPORT transport);
1308 
1309 /*******************************************************************************
1310  *
1311  * Function         BTM_ReadTrustedMask
1312  *
1313  * Description      Get trusted mask for the device
1314  *
1315  * Returns          NULL, if the device record is not found.
1316  *                  otherwise, the trusted mask
1317  *
1318  ******************************************************************************/
1319 extern uint32_t* BTM_ReadTrustedMask(BD_ADDR bd_addr);
1320 
1321 /*******************************************************************************
1322  *
1323  * Function         BTM_SetPinType
1324  *
1325  * Description      Set PIN type for the device.
1326  *
1327  * Returns          void
1328  *
1329  ******************************************************************************/
1330 extern void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code,
1331                            uint8_t pin_code_len);
1332 
1333 /*******************************************************************************
1334  *
1335  * Function         BTM_SetPairableMode
1336  *
1337  * Description      Enable or disable pairing
1338  *
1339  * Parameters       allow_pairing - (true or false) whether or not the device
1340  *                      allows pairing.
1341  *                  connect_only_paired - (true or false) whether or not to
1342  *                      only allow paired devices to connect.
1343  *
1344  * Returns          void
1345  *
1346  ******************************************************************************/
1347 extern void BTM_SetPairableMode(bool allow_pairing, bool connect_only_paired);
1348 
1349 /*******************************************************************************
1350  *
1351  * Function         BTM_SetSecureConnectionsOnly
1352  *
1353  * Description      Enable or disable default treatment for Mode 4 Level 0
1354  *                  services
1355  *
1356  * Parameter        secure_connections_only_mode - (true or false)
1357  *                  true means that the device should treat Mode 4 Level 0
1358  *                  services as services of other levels.
1359  *                  false means that the device should provide default
1360  *                  treatment for Mode 4 Level 0 services.
1361  *
1362  * Returns          void
1363  *
1364  ******************************************************************************/
1365 extern void BTM_SetSecureConnectionsOnly(bool secure_connections_only_mode);
1366 
1367 /*******************************************************************************
1368  *
1369  * Function         BTM_SetSecurityLevel
1370  *
1371  * Description      Register service security level with Security Manager.  Each
1372  *                  service must register its requirements regardless of the
1373  *                  security level that is used.  This API is called once for
1374  *                  originators and again for acceptors of connections.
1375  *
1376  * Returns          true if registered OK, else false
1377  *
1378  ******************************************************************************/
1379 extern bool BTM_SetSecurityLevel(bool is_originator, const char* p_name,
1380                                  uint8_t service_id, uint16_t sec_level,
1381                                  uint16_t psm, uint32_t mx_proto_id,
1382                                  uint32_t mx_chan_id);
1383 
1384 /*******************************************************************************
1385  *
1386  * Function         BTM_SetOutService
1387  *
1388  * Description      This function is called to set the service for
1389  *                  outgoing connection.
1390  *
1391  * Returns          void
1392  *
1393  ******************************************************************************/
1394 extern void BTM_SetOutService(BD_ADDR bd_addr, uint8_t service_id,
1395                               uint32_t mx_chan_id);
1396 
1397 /*******************************************************************************
1398  *
1399  * Function         BTM_SecClrService
1400  *
1401  * Description      Removes specified service record(s) from the security
1402  *                  database. All service records with the specified name are
1403  *                  removed. Typically used only by devices with limited RAM
1404  *                  so that it can reuse an old security service record.
1405  *
1406  * Returns          Number of records that were freed.
1407  *
1408  ******************************************************************************/
1409 extern uint8_t BTM_SecClrService(uint8_t service_id);
1410 
1411 /*******************************************************************************
1412  *
1413  * Function         BTM_SecAddDevice
1414  *
1415  * Description      Add/modify device.  This function will be normally called
1416  *                  during host startup to restore all required information
1417  *                  stored in the NVRAM.
1418  *                  dev_class, bd_name, link_key, and features are NULL if
1419  *                  unknown
1420  *
1421  * Returns          true if added OK, else false
1422  *
1423  ******************************************************************************/
1424 extern bool BTM_SecAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class,
1425                              BD_NAME bd_name, uint8_t* features,
1426                              uint32_t trusted_mask[], LINK_KEY link_key,
1427                              uint8_t key_type, tBTM_IO_CAP io_cap,
1428                              uint8_t pin_length);
1429 
1430 /*******************************************************************************
1431  *
1432  * Function         BTM_SecDeleteDevice
1433  *
1434  * Description      Free resources associated with the device.
1435  *
1436  * Returns          true if rmoved OK, false if not found
1437  *
1438  ******************************************************************************/
1439 extern bool BTM_SecDeleteDevice(BD_ADDR bd_addr);
1440 
1441 /*******************************************************************************
1442  *
1443  * Function         BTM_SecClearSecurityFlags
1444  *
1445  * Description      Reset the security flags (mark as not-paired) for a given
1446  *                  remove device.
1447  *
1448  ******************************************************************************/
1449 extern void BTM_SecClearSecurityFlags(BD_ADDR bd_addr);
1450 
1451 /*******************************************************************************
1452  *
1453  * Function         BTM_SecGetDeviceLinkKey
1454  *
1455  * Description      This function is called to obtain link key for the device
1456  *                  it returns BTM_SUCCESS if link key is available, or
1457  *                  BTM_UNKNOWN_ADDR if Security Manager does not know about
1458  *                  the device or device record does not contain link key info
1459  *
1460  * Returns          BTM_SUCCESS if successful, otherwise error code
1461  *
1462  ******************************************************************************/
1463 extern tBTM_STATUS BTM_SecGetDeviceLinkKey(BD_ADDR bd_addr, LINK_KEY link_key);
1464 
1465 /*******************************************************************************
1466  *
1467  * Function         BTM_SecGetDeviceLinkKeyType
1468  *
1469  * Description      This function is called to obtain link key type for the
1470  *                  device.
1471  *                  it returns BTM_SUCCESS if link key is available, or
1472  *                  BTM_UNKNOWN_ADDR if Security Manager does not know about
1473  *                  the device or device record does not contain link key info
1474  *
1475  * Returns          BTM_LKEY_TYPE_IGNORE if link key is unknown, link type
1476  *                  otherwise.
1477  *
1478  ******************************************************************************/
1479 extern tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType(BD_ADDR bd_addr);
1480 
1481 /*******************************************************************************
1482  *
1483  * Function         BTM_PINCodeReply
1484  *
1485  * Description      This function is called after Security Manager submitted
1486  *                  PIN code request to the UI.
1487  *
1488  * Parameters:      bd_addr      - Address of the device for which PIN was
1489  *                                 requested
1490  *                  res          - result of the operation BTM_SUCCESS if
1491  *                                 success
1492  *                  pin_len      - length in bytes of the PIN Code
1493  *                  p_pin        - pointer to array with the PIN Code
1494  *                  trusted_mask - bitwise OR of trusted services
1495  *                                 (array of uint32_t)
1496  *
1497  * Returns          void
1498  *
1499  ******************************************************************************/
1500 extern void BTM_PINCodeReply(BD_ADDR bd_addr, uint8_t res, uint8_t pin_len,
1501                              uint8_t* p_pin, uint32_t trusted_mask[]);
1502 
1503 /*******************************************************************************
1504  *
1505  * Function         BTM_SecBond
1506  *
1507  * Description      This function is called to perform bonding with peer device.
1508  *
1509  * Parameters:      bd_addr      - Address of the device to bond
1510  *                  pin_len      - length in bytes of the PIN Code
1511  *                  p_pin        - pointer to array with the PIN Code
1512  *                  trusted_mask - bitwise OR of trusted services
1513  *                                 (array of uint32_t)
1514  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
1515  *
1516  ******************************************************************************/
1517 extern tBTM_STATUS BTM_SecBond(BD_ADDR bd_addr, uint8_t pin_len, uint8_t* p_pin,
1518                                uint32_t trusted_mask[]);
1519 
1520 /*******************************************************************************
1521  *
1522  * Function         BTM_SecBondByTransport
1523  *
1524  * Description      Perform bonding by designated transport
1525  *
1526  * Parameters:      bd_addr      - Address of the device to bond
1527  *                  pin_len      - length in bytes of the PIN Code
1528  *                  p_pin        - pointer to array with the PIN Code
1529  *                  trusted_mask - bitwise OR of trusted services
1530  *                                 (array of uint32_t)
1531  *                  transport :  Physical transport to use for bonding
1532  *                               (BR/EDR or LE)
1533  *
1534  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
1535  *
1536  ******************************************************************************/
1537 extern tBTM_STATUS BTM_SecBondByTransport(BD_ADDR bd_addr,
1538                                           tBT_TRANSPORT transport,
1539                                           uint8_t pin_len, uint8_t* p_pin,
1540                                           uint32_t trusted_mask[]);
1541 
1542 /*******************************************************************************
1543  *
1544  * Function         BTM_SecBondCancel
1545  *
1546  * Description      This function is called to cancel ongoing bonding process
1547  *                  with peer device.
1548  *
1549  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
1550  *
1551  ******************************************************************************/
1552 extern tBTM_STATUS BTM_SecBondCancel(BD_ADDR bd_addr);
1553 
1554 /*******************************************************************************
1555  *
1556  * Function         BTM_SetEncryption
1557  *
1558  * Description      This function is called to ensure that connection is
1559  *                  encrypted.  Should be called only on an open connection.
1560  *                  Typically only needed for connections that first want to
1561  *                  bring up unencrypted links, then later encrypt them.
1562  *
1563  * Parameters:      bd_addr       - Address of the peer device
1564  *                  transport     - Link transport
1565  *                  p_callback    - Pointer to callback function called if
1566  *                                  this function returns PENDING after required
1567  *                                  procedures are completed.  Can be set to
1568  *                                  NULL if status is not desired.
1569  *                  p_ref_data    - pointer to any data the caller wishes to
1570  *                                  receive in the callback function upon
1571  *                                  completion.
1572  *                                  can be set to NULL if not used.
1573  *                  sec_act       - LE security action, unused for BR/EDR
1574  *
1575  * Returns          BTM_SUCCESS   - already encrypted
1576  *                  BTM_PENDING   - command will be returned in the callback
1577  *                  BTM_WRONG_MODE- connection not up.
1578  *                  BTM_BUSY      - security procedures are currently active
1579  *                  BTM_MODE_UNSUPPORTED - if security manager not linked in.
1580  *
1581  ******************************************************************************/
1582 extern tBTM_STATUS BTM_SetEncryption(BD_ADDR bd_addr, tBT_TRANSPORT transport,
1583                                      tBTM_SEC_CBACK* p_callback,
1584                                      void* p_ref_data,
1585                                      tBTM_BLE_SEC_ACT sec_act);
1586 
1587 /*******************************************************************************
1588  *
1589  * Function         BTM_ConfirmReqReply
1590  *
1591  * Description      This function is called to confirm the numeric value for
1592  *                  Simple Pairing in response to BTM_SP_CFM_REQ_EVT
1593  *
1594  * Parameters:      res           - result of the operation BTM_SUCCESS if
1595  *                                  success
1596  *                  bd_addr       - Address of the peer device
1597  *
1598  ******************************************************************************/
1599 extern void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr);
1600 
1601 /*******************************************************************************
1602  *
1603  * Function         BTM_PasskeyReqReply
1604  *
1605  * Description      This function is called to provide the passkey for
1606  *                  Simple Pairing in response to BTM_SP_KEY_REQ_EVT
1607  *
1608  * Parameters:      res           - result of the operation BTM_SUCCESS if
1609  *                                  success
1610  *                  bd_addr       - Address of the peer device
1611  *                  passkey       - numeric value in the range of
1612  *                                  0 - 999999(0xF423F).
1613  *
1614  ******************************************************************************/
1615 extern void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr,
1616                                 uint32_t passkey);
1617 
1618 /*******************************************************************************
1619  *
1620  * Function         BTM_SendKeypressNotif
1621  *
1622  * Description      This function is used during the passkey entry model
1623  *                  by a device with KeyboardOnly IO capabilities
1624  *                  (very likely to be a HID Device).
1625  *                  It is called by a HID Device to inform the remote device
1626  *                  when a key has been entered or erased.
1627  *
1628  * Parameters:      bd_addr - Address of the peer device
1629  *                  type - notification type
1630  *
1631  ******************************************************************************/
1632 extern void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type);
1633 
1634 /*******************************************************************************
1635  *
1636  * Function         BTM_IoCapRsp
1637  *
1638  * Description      This function is called in response to BTM_SP_IO_REQ_EVT
1639  *                  When the event data io_req.oob_data is set to
1640  *                  BTM_OOB_UNKNOWN by the tBTM_SP_CALLBACK implementation, this
1641  *                  function is called to provide the actual response
1642  *
1643  * Parameters:      bd_addr - Address of the peer device
1644  *                  io_cap  - The IO capability of local device.
1645  *                  oob     - BTM_OOB_NONE or BTM_OOB_PRESENT.
1646  *                  auth_req- MITM protection required or not.
1647  *
1648  ******************************************************************************/
1649 extern void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap, tBTM_OOB_DATA oob,
1650                          tBTM_AUTH_REQ auth_req);
1651 
1652 /*******************************************************************************
1653  *
1654  * Function         BTM_ReadLocalOobData
1655  *
1656  * Description      This function is called to read the local OOB data from
1657  *                  LM
1658  *
1659  ******************************************************************************/
1660 extern void BTM_ReadLocalOobData(void);
1661 
1662 /*******************************************************************************
1663  *
1664  * Function         BTM_RemoteOobDataReply
1665  *
1666  * Description      This function is called to provide the remote OOB data for
1667  *                  Simple Pairing in response to BTM_SP_RMT_OOB_EVT
1668  *
1669  * Parameters:      bd_addr     - Address of the peer device
1670  *                  c           - simple pairing Hash C.
1671  *                  r           - simple pairing Randomizer  C.
1672  *
1673  ******************************************************************************/
1674 extern void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr,
1675                                    BT_OCTET16 c, BT_OCTET16 r);
1676 
1677 /*******************************************************************************
1678  *
1679  * Function         BTM_BuildOobData
1680  *
1681  * Description      This function is called to build the OOB data payload to
1682  *                  be sent over OOB (non-Bluetooth) link
1683  *
1684  * Parameters:      p_data  - the location for OOB data
1685  *                  max_len - p_data size.
1686  *                  c       - simple pairing Hash C.
1687  *                  r       - simple pairing Randomizer  C.
1688  *                  name_len- 0, local device name would not be included.
1689  *                            otherwise, the local device name is included for
1690  *                            up to this specified length
1691  *
1692  * Returns          Number of bytes in p_data.
1693  *
1694  ******************************************************************************/
1695 extern uint16_t BTM_BuildOobData(uint8_t* p_data, uint16_t max_len,
1696                                  BT_OCTET16 c, BT_OCTET16 r, uint8_t name_len);
1697 
1698 /*******************************************************************************
1699  *
1700  * Function         BTM_BothEndsSupportSecureConnections
1701  *
1702  * Description      This function is called to check if both the local device
1703  *                  and the peer device specified by bd_addr support BR/EDR
1704  *                  Secure Connections.
1705  *
1706  * Parameters:      bd_addr - address of the peer
1707  *
1708  * Returns          true if BR/EDR Secure Connections are supported by both
1709  *                  local and the remote device.
1710  *                  else false.
1711  *
1712  ******************************************************************************/
1713 extern bool BTM_BothEndsSupportSecureConnections(BD_ADDR bd_addr);
1714 
1715 /*******************************************************************************
1716  *
1717  * Function         BTM_PeerSupportsSecureConnections
1718  *
1719  * Description      This function is called to check if the peer supports
1720  *                  BR/EDR Secure Connections.
1721  *
1722  * Parameters:      bd_addr - address of the peer
1723  *
1724  * Returns          true if BR/EDR Secure Connections are supported by the peer,
1725  *                  else false.
1726  *
1727  ******************************************************************************/
1728 extern bool BTM_PeerSupportsSecureConnections(BD_ADDR bd_addr);
1729 
1730 /*******************************************************************************
1731  *
1732  * Function         BTM_ReadOobData
1733  *
1734  * Description      This function is called to parse the OOB data payload
1735  *                  received over OOB (non-Bluetooth) link
1736  *
1737  * Parameters:      p_data  - the location for OOB data
1738  *                  eir_tag - The associated EIR tag to read the data.
1739  *                  *p_len(output) - the length of the data with the given tag.
1740  *
1741  * Returns          the beginning of the data with the given tag.
1742  *                  NULL, if the tag is not found.
1743  *
1744  ******************************************************************************/
1745 extern uint8_t* BTM_ReadOobData(uint8_t* p_data, uint8_t eir_tag,
1746                                 uint8_t* p_len);
1747 
1748 /*******************************************************************************
1749  *
1750  * Function         BTM_SecReadDevName
1751  *
1752  * Description      Looks for the device name in the security database for the
1753  *                  specified BD address.
1754  *
1755  * Returns          Pointer to the name or NULL
1756  *
1757  ******************************************************************************/
1758 extern char* BTM_SecReadDevName(BD_ADDR bd_addr);
1759 
1760 /*****************************************************************************
1761  *  POWER MANAGEMENT FUNCTIONS
1762  ****************************************************************************/
1763 /*******************************************************************************
1764  *
1765  * Function         BTM_PmRegister
1766  *
1767  * Description      register or deregister with power manager
1768  *
1769  * Returns          BTM_SUCCESS if successful,
1770  *                  BTM_NO_RESOURCES if no room to hold registration
1771  *                  BTM_ILLEGAL_VALUE
1772  *
1773  ******************************************************************************/
1774 extern tBTM_STATUS BTM_PmRegister(uint8_t mask, uint8_t* p_pm_id,
1775                                   tBTM_PM_STATUS_CBACK* p_cb);
1776 
1777 /*******************************************************************************
1778  *
1779  * Function         BTM_SetPowerMode
1780  *
1781  * Description      store the mode in control block or
1782  *                  alter ACL connection behavior.
1783  *
1784  * Returns          BTM_SUCCESS if successful,
1785  *                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
1786  *
1787  ******************************************************************************/
1788 extern tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, BD_ADDR remote_bda,
1789                                     tBTM_PM_PWR_MD* p_mode);
1790 
1791 /*******************************************************************************
1792  *
1793  * Function         BTM_ReadPowerMode
1794  *
1795  * Description      This returns the current mode for a specific
1796  *                  ACL connection.
1797  *
1798  * Input Param      remote_bda - device address of desired ACL connection
1799  *
1800  * Output Param     p_mode - address where the current mode is copied into.
1801  *                          BTM_ACL_MODE_NORMAL
1802  *                          BTM_ACL_MODE_HOLD
1803  *                          BTM_ACL_MODE_SNIFF
1804  *                          BTM_ACL_MODE_PARK
1805  *                          (valid only if return code is BTM_SUCCESS)
1806  *
1807  * Returns          BTM_SUCCESS if successful,
1808  *                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
1809  *
1810  ******************************************************************************/
1811 extern tBTM_STATUS BTM_ReadPowerMode(BD_ADDR remote_bda, tBTM_PM_MODE* p_mode);
1812 
1813 /*******************************************************************************
1814  *
1815  * Function         BTM_SetSsrParams
1816  *
1817  * Description      This sends the given SSR parameters for the given ACL
1818  *                  connection if it is in ACTIVE mode.
1819  *
1820  * Input Param      remote_bda - device address of desired ACL connection
1821  *                  max_lat    - maximum latency (in 0.625ms)(0-0xFFFE)
1822  *                  min_rmt_to - minimum remote timeout
1823  *                  min_loc_to - minimum local timeout
1824  *
1825  *
1826  * Returns          BTM_SUCCESS if the HCI command is issued successful,
1827  *                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
1828  *                  BTM_CMD_STORED if the command is stored
1829  *
1830  ******************************************************************************/
1831 extern tBTM_STATUS BTM_SetSsrParams(BD_ADDR remote_bda, uint16_t max_lat,
1832                                     uint16_t min_rmt_to, uint16_t min_loc_to);
1833 
1834 /*******************************************************************************
1835  *
1836  * Function         BTM_GetHCIConnHandle
1837  *
1838  * Description      This function is called to get the handle for an ACL
1839  *                  connection to a specific remote BD Address.
1840  *
1841  * Returns          the handle of the connection, or 0xFFFF if none.
1842  *
1843  ******************************************************************************/
1844 extern uint16_t BTM_GetHCIConnHandle(const BD_ADDR remote_bda,
1845                                      tBT_TRANSPORT transport);
1846 
1847 /*******************************************************************************
1848  *
1849  * Function         BTM_DeleteStoredLinkKey
1850  *
1851  * Description      This function is called to delete link key for the specified
1852  *                  device addresses from the NVRAM storage attached to the
1853  *                  Bluetooth controller.
1854  *
1855  * Parameters:      bd_addr      - Addresses of the devices
1856  *                  p_cb         - Call back function to be called to return
1857  *                                 the results
1858  *
1859  ******************************************************************************/
1860 extern tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB* p_cb);
1861 
1862 /*******************************************************************************
1863  *
1864  * Function         BTM_WriteEIR
1865  *
1866  * Description      This function is called to write EIR data to controller.
1867  *
1868  * Parameters       p_buff - allocated HCI command buffer including extended
1869  *                           inquriry response
1870  *
1871  * Returns          BTM_SUCCESS  - if successful
1872  *                  BTM_MODE_UNSUPPORTED - if local device cannot support it
1873  *
1874  ******************************************************************************/
1875 extern tBTM_STATUS BTM_WriteEIR(BT_HDR* p_buff);
1876 
1877 /*******************************************************************************
1878  *
1879  * Function         BTM_HasEirService
1880  *
1881  * Description      This function is called to know if UUID in bit map of UUID.
1882  *
1883  * Parameters       p_eir_uuid - bit map of UUID list
1884  *                  uuid16 - UUID 16-bit
1885  *
1886  * Returns          true - if found
1887  *                  false - if not found
1888  *
1889  ******************************************************************************/
1890 extern bool BTM_HasEirService(uint32_t* p_eir_uuid, uint16_t uuid16);
1891 
1892 /*******************************************************************************
1893  *
1894  * Function         BTM_HasInquiryEirService
1895  *
1896  * Description      Return if a UUID is in the bit map of a UUID list.
1897  *
1898  * Parameters       p_results - inquiry results
1899  *                  uuid16 - UUID 16-bit
1900  *
1901  * Returns          BTM_EIR_FOUND - if found
1902  *                  BTM_EIR_NOT_FOUND - if not found and it is a complete list
1903  *                  BTM_EIR_UNKNOWN - if not found and it is not complete list
1904  *
1905  ******************************************************************************/
1906 extern tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService(
1907     tBTM_INQ_RESULTS* p_results, uint16_t uuid16);
1908 
1909 /*******************************************************************************
1910  *
1911  * Function         BTM_AddEirService
1912  *
1913  * Description      This function is called to add a service in the bit map UUID
1914  *                  list.
1915  *
1916  * Parameters       p_eir_uuid - bit mask of UUID list for EIR
1917  *                  uuid16 - UUID 16-bit
1918  *
1919  * Returns          None
1920  *
1921  ******************************************************************************/
1922 extern void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16);
1923 
1924 /*******************************************************************************
1925  *
1926  * Function         BTM_RemoveEirService
1927  *
1928  * Description      This function is called to remove a service from the bit map
1929  *                  UUID list.
1930  *
1931  * Parameters       p_eir_uuid - bit mask of UUID list for EIR
1932  *                  uuid16 - UUID 16-bit
1933  *
1934  * Returns          None
1935  *
1936  ******************************************************************************/
1937 extern void BTM_RemoveEirService(uint32_t* p_eir_uuid, uint16_t uuid16);
1938 
1939 /*******************************************************************************
1940  *
1941  * Function         BTM_GetEirSupportedServices
1942  *
1943  * Description      This function is called to get UUID list from bit map UUID
1944  *                  list.
1945  *
1946  * Parameters       p_eir_uuid - bit mask of UUID list for EIR
1947  *                  p - reference of current pointer of EIR
1948  *                  max_num_uuid16 - max number of UUID can be written in EIR
1949  *                  num_uuid16 - number of UUID have been written in EIR
1950  *
1951  * Returns          BTM_EIR_MORE_16BITS_UUID_TYPE, if it has more than max
1952  *                  BTM_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise
1953  *
1954  ******************************************************************************/
1955 extern uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p,
1956                                            uint8_t max_num_uuid16,
1957                                            uint8_t* p_num_uuid16);
1958 
1959 /*******************************************************************************
1960  *
1961  * Function         BTM_GetEirUuidList
1962  *
1963  * Description      This function parses EIR and returns UUID list.
1964  *
1965  * Parameters       p_eir - EIR
1966  *                  eirl_len - EIR len
1967  *                  uuid_size - LEN_UUID_16, LEN_UUID_32, LEN_UUID_128
1968  *                  p_num_uuid - return number of UUID in found list
1969  *                  p_uuid_list - return UUID 16-bit list
1970  *                  max_num_uuid - maximum number of UUID to be returned
1971  *
1972  * Returns          0 - if not found
1973  *                  BTM_EIR_COMPLETE_16BITS_UUID_TYPE
1974  *                  BTM_EIR_MORE_16BITS_UUID_TYPE
1975  *                  BTM_EIR_COMPLETE_32BITS_UUID_TYPE
1976  *                  BTM_EIR_MORE_32BITS_UUID_TYPE
1977  *                  BTM_EIR_COMPLETE_128BITS_UUID_TYPE
1978  *                  BTM_EIR_MORE_128BITS_UUID_TYPE
1979  *
1980  ******************************************************************************/
1981 extern uint8_t BTM_GetEirUuidList(uint8_t* p_eir, size_t eir_len,
1982                                   uint8_t uuid_size, uint8_t* p_num_uuid,
1983                                   uint8_t* p_uuid_list, uint8_t max_num_uuid);
1984 
1985 /*****************************************************************************
1986  *  SCO OVER HCI
1987  ****************************************************************************/
1988 /*******************************************************************************
1989  *
1990  * Function         BTM_ConfigScoPath
1991  *
1992  * Description      This function enable/disable SCO over HCI and registers SCO
1993  *                  data callback if SCO over HCI is enabled.
1994  *
1995  * Parameter        path: SCO or HCI
1996  *                  p_sco_data_cb: callback function or SCO data if path is set
1997  *                                 to transport.
1998  *                  p_pcm_param: pointer to the PCM interface parameter. If a
1999  *                               NULL pointer is used, the PCM parameter
2000  *                               maintained in the control block will be used;
2001  *                               otherwise update the control block value.
2002  *                  err_data_rpt: Lisbon feature to enable the erronous data
2003  *                                report or not.
2004  *
2005  * Returns          BTM_SUCCESS if the successful.
2006  *                  BTM_NO_RESOURCES: no rsource to start the command.
2007  *                  BTM_ILLEGAL_VALUE: invalid callback function pointer.
2008  *                  BTM_CMD_STARTED : Command sent. Waiting for command
2009  *                                    complete event.
2010  *
2011  *
2012  ******************************************************************************/
2013 extern tBTM_STATUS BTM_ConfigScoPath(esco_data_path_t path,
2014                                      tBTM_SCO_DATA_CB* p_sco_data_cb,
2015                                      tBTM_SCO_PCM_PARAM* p_pcm_param,
2016                                      bool err_data_rpt);
2017 
2018 /*******************************************************************************
2019  *
2020  * Function         BTM_WriteScoData
2021  *
2022  * Description      This function write SCO data to a specified instance. The
2023  *                  data to be written p_buf needs to carry an offset of
2024  *                  HCI_SCO_PREAMBLE_SIZE bytes, and the data length can not
2025  *                  exceed BTM_SCO_DATA_SIZE_MAX bytes, whose default value is
2026  *                  set to 60 and is configurable. Data longer than the maximum
2027  *                  bytes will be truncated.
2028  *
2029  * Returns          BTM_SUCCESS: data write is successful
2030  *                  BTM_ILLEGAL_VALUE: SCO data contains illegal offset value.
2031  *                  BTM_SCO_BAD_LENGTH: SCO data length exceeds the max SCO
2032  *                                      packet size.
2033  *                  BTM_NO_RESOURCES: no resources.
2034  *                  BTM_UNKNOWN_ADDR: unknown SCO connection handle, or SCO is
2035  *                                    not routed via HCI.
2036  *
2037  *
2038  ******************************************************************************/
2039 extern tBTM_STATUS BTM_WriteScoData(uint16_t sco_inx, BT_HDR* p_buf);
2040 
2041 /*******************************************************************************
2042  *
2043  * Function         BTM_SetARCMode
2044  *
2045  * Description      Send Audio Routing Control command.
2046  *
2047  * Returns          void
2048  *
2049  ******************************************************************************/
2050 extern void BTM_SetARCMode(uint8_t iface, uint8_t arc_mode,
2051                            tBTM_VSC_CMPL_CB* p_arc_cb);
2052 
2053 /*******************************************************************************
2054  *
2055  * Function         BTM_PCM2Setup_Write
2056  *
2057  * Description      Send PCM2_Setup write command.
2058  *
2059  * Returns          void
2060  *
2061  ******************************************************************************/
2062 extern void BTM_PCM2Setup_Write(bool clk_master, tBTM_VSC_CMPL_CB* p_arc_cb);
2063 
2064 /*******************************************************************************
2065  *
2066  * Function         BTM_PM_ReadControllerState
2067  *
2068  * Description      This function is called to obtain the controller state
2069  *
2070  * Returns          Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and
2071  *                                    BTM_CONTRL_IDLE)
2072  *
2073  ******************************************************************************/
2074 extern tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void);
2075 
2076 #endif /* BTM_API_H */
2077