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 functions that handle BTM interface functions for the
22 * Bluetooth device including Rest, HCI buffer size and others
23 *
24 ******************************************************************************/
25
26 #include <stdlib.h>
27 #include <string.h>
28 #include <stdio.h>
29 #include <stddef.h>
30
31 #include "bt_types.h"
32 #include "hcimsgs.h"
33 #include "btu.h"
34 #include "btm_int.h"
35 #include "l2c_int.h"
36
37 #if BLE_INCLUDED == TRUE
38 #include "gatt_int.h"
39
40 #endif /* BLE_INCLUDED */
41
42 /* BTM_APP_DEV_INIT should be defined if additional controller initialization is
43 ** needed by the application to be performed after the HCI reset
44 */
45 #ifdef BTM_APP_DEV_INIT
46 extern void BTM_APP_DEV_INIT(void);
47 #endif
48
49 #ifdef BTA_PRM_CHECK_FW_VER
50 extern BOOLEAN BTA_PRM_CHECK_FW_VER(UINT8 *p);
51 #endif
52
53 #ifndef TT_DEV_RESET_MASK
54 #define TT_DEV_RESET_MASK 0xff
55 #endif
56
57 /********************************************************************************/
58 /* L O C A L D A T A D E F I N I T I O N S */
59 /********************************************************************************/
60
61 /* The default class of device. */
62 #ifndef BTM_INIT_CLASS_OF_DEVICE
63 #define BTM_INIT_CLASS_OF_DEVICE "\x00\x1F\x00"
64 #endif
65
66 #ifndef BTM_DEV_RESET_TIMEOUT
67 #define BTM_DEV_RESET_TIMEOUT 4
68 #endif
69
70 #define BTM_DEV_REPLY_TIMEOUT 2 /* 1 second expiration time is not good. Timer may start between 0 and 1 second. */
71 /* if it starts at the very end of the 0 second, timer will expire really easily. */
72
73 #define BTM_INFO_TIMEOUT 5 /* 5 seconds for info response */
74
75 /* After Reset a timeout can be specified in the target.h for specific targets
76 * that may require additional time to reset
77 * otherwise no timeout is required
78 */
79 #ifndef BTM_AFTER_RESET_TIMEOUT
80 #define BTM_AFTER_RESET_TIMEOUT 0
81 #endif
82
83 /* Internal baseband so the parameters such as local features, version etc. are known
84 so there is no need to issue HCI commands and wait for responses at BTM initialization */
85 #ifndef BTM_INTERNAL_BB
86 #define BTM_INTERNAL_BB FALSE
87 #endif
88
89 /* The local version information in the format specified in the HCI read local version
90 response message */
91 #ifndef BTM_INTERNAL_LOCAL_VER
92 #define BTM_INTERNAL_LOCAL_VER {0x00, 0x01, 0x05, 0x81, 0x01, 0x30, 0x00, 0x40, 0x8D}
93 #endif
94
95 /* The local features information in the format specified in the HCI read local features
96 response message */
97 #ifndef BTM_INTERNAL_LOCAL_FEA
98 #define BTM_INTERNAL_LOCAL_FEA {0x00, 0xFF, 0xF9, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}
99 #endif
100
101 #ifndef BTM_SET_DEV_NAME_UPON_RESET
102 #define BTM_SET_DEV_NAME_UPON_RESET TRUE
103 #endif
104
105 /* host SCO buffer size */
106 #ifndef BTM_SCO_HOST_BUF_SIZE
107 #define BTM_SCO_HOST_BUF_SIZE 0xff
108 #endif
109
110 /********************************************************************************/
111 /* L O C A L F U N C T I O N P R O T O T Y P E S */
112 /********************************************************************************/
113 static void btm_dev_reset (void);
114 static void btm_after_reset_hold_complete (void);
115 static void btm_continue_reset (void);
116
117 static void btm_get_local_ext_features (UINT8 page_number);
118 static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p_features);
119 static void btm_read_all_lmp_features_complete (UINT8 max_page_number);
120 static void btm_set_lmp_features_host_may_support (UINT8 max_page_number);
121 static void btm_get_local_features (void);
122 static void btm_issue_host_support_for_lmp_features (void);
123 static void btm_read_local_supported_cmds (UINT8 local_controller_id);
124
125 #if BLE_INCLUDED == TRUE
126 static void btm_read_ble_local_supported_features (void);
127 #endif
128
129 /*******************************************************************************
130 **
131 ** Function btm_dev_init
132 **
133 ** Description This function is on the BTM startup
134 **
135 ** Returns void
136 **
137 *******************************************************************************/
btm_dev_init(void)138 void btm_dev_init (void)
139 {
140 #if 0 /* cleared in btm_init; put back in if called from anywhere else! */
141 memset (&btm_cb.devcb, 0, sizeof (tBTM_DEVCB));
142 #endif
143
144 /* Initialize nonzero defaults */
145 #if (BTM_MAX_LOC_BD_NAME_LEN > 0)
146 memset(btm_cb.cfg.bd_name, 0, sizeof(tBTM_LOC_BD_NAME));
147 #if (BTM_USE_DEF_LOCAL_NAME == TRUE)
148 BCM_STRNCPY_S(btm_cb.cfg.bd_name, sizeof(btm_cb.cfg.bd_name), BTM_DEF_LOCAL_NAME, BTM_MAX_LOC_BD_NAME_LEN);
149 #endif
150 #endif
151
152 btm_cb.devcb.reset_timer.param = (TIMER_PARAM_TYPE)TT_DEV_RESET;
153 btm_cb.devcb.rln_timer.param = (TIMER_PARAM_TYPE)TT_DEV_RLN;
154 btm_cb.devcb.rlinkp_timer.param = (TIMER_PARAM_TYPE)TT_DEV_RLNKP;
155
156 btm_cb.btm_acl_pkt_types_supported = BTM_ACL_PKT_TYPES_MASK_DH1 + BTM_ACL_PKT_TYPES_MASK_DM1 +
157 BTM_ACL_PKT_TYPES_MASK_DH3 + BTM_ACL_PKT_TYPES_MASK_DM3 +
158 BTM_ACL_PKT_TYPES_MASK_DH5 + BTM_ACL_PKT_TYPES_MASK_DM5;
159
160 btm_cb.btm_sco_pkt_types_supported = BTM_SCO_PKT_TYPES_MASK_HV1 +
161 BTM_SCO_PKT_TYPES_MASK_HV2 +
162 BTM_SCO_PKT_TYPES_MASK_HV3 +
163 BTM_SCO_PKT_TYPES_MASK_EV3 +
164 BTM_SCO_PKT_TYPES_MASK_EV4 +
165 BTM_SCO_PKT_TYPES_MASK_EV5;
166
167 btm_cb.first_disabled_channel = 0xff; /* To allow disabling 0th channel alone */
168 btm_cb.last_disabled_channel = 0xff; /* To allow disabling 0th channel alone */
169
170 #if (BTM_AUTOMATIC_HCI_RESET == TRUE)
171
172 #if (BTM_FIRST_RESET_DELAY > 0)
173 btm_cb.devcb.state = BTM_DEV_STATE_WAIT_RESET_CMPLT;
174 btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_FIRST_RESET_DELAY);
175 #else
176 btm_dev_reset();
177 #endif
178
179 #else
180 BTM_TRACE_EVENT0 ("BTM_AUTOMATIC_HCI_RESET is FALSE, so skip btm reset for now");
181 #endif
182
183 }
184
185
186 /*******************************************************************************
187 **
188 ** Function btm_db_reset
189 **
190 ** Description This function is called by BTM_DeviceReset and clears out any
191 ** pending callbacks for inquiries, discoveries, other pending
192 ** functions that may be in progress.
193 **
194 ** Returns void
195 **
196 *******************************************************************************/
btm_db_reset(void)197 static void btm_db_reset (void)
198 {
199 tBTM_CMPL_CB *p_cb;
200 tBTM_STATUS status = BTM_DEV_RESET;
201
202 btm_inq_db_reset();
203
204 if (btm_cb.devcb.p_rln_cmpl_cb)
205 {
206 p_cb = btm_cb.devcb.p_rln_cmpl_cb;
207 btm_cb.devcb.p_rln_cmpl_cb = NULL;
208
209 if (p_cb)
210 (*p_cb)((void *) NULL);
211 }
212
213 if (btm_cb.devcb.p_rlinkp_cmpl_cb)
214 {
215 p_cb = btm_cb.devcb.p_rlinkp_cmpl_cb;
216 btm_cb.devcb.p_rlinkp_cmpl_cb = NULL;
217
218 if (p_cb)
219 (*p_cb)((void *) &status);
220 }
221
222 if (btm_cb.devcb.p_rssi_cmpl_cb)
223 {
224 p_cb = btm_cb.devcb.p_rssi_cmpl_cb;
225 btm_cb.devcb.p_rssi_cmpl_cb = NULL;
226
227 if (p_cb)
228 (*p_cb)((tBTM_RSSI_RESULTS *) &status);
229 }
230 }
231
232
233
234 /*******************************************************************************
235 **
236 ** Function btm_dev_absent
237 **
238 ** Description This function is called by when it is detected that the
239 ** device is not connected any more.
240 **
241 ** Returns void
242 **
243 *******************************************************************************/
btm_dev_absent(void)244 void btm_dev_absent (void)
245 {
246 btm_cb.devcb.state = BTM_DEV_STATE_WAIT_RESET_CMPLT;
247
248 btm_db_reset ();
249 btm_inq_db_reset();
250
251 /* If anyone wants device status notifications, give him one */
252 btm_report_device_status (BTM_DEV_STATUS_DOWN);
253
254 btu_stop_timer (&btm_cb.devcb.reset_timer);
255 }
256
257
258 /*******************************************************************************
259 **
260 ** Function BTM_DeviceReset
261 **
262 ** Description This function is called to reset the HCI. Callback function
263 ** if provided is called when startup of the device is
264 ** completed.
265 **
266 ** Returns void
267 **
268 *******************************************************************************/
BTM_DeviceReset(tBTM_CMPL_CB * p_cb)269 void BTM_DeviceReset (tBTM_CMPL_CB *p_cb)
270 {
271 tBTM_STATUS status;
272
273 /* If device is already resetting, do not allow another */
274 if ((!btm_cb.devcb.p_reset_cmpl_cb) || (btm_cb.devcb.p_reset_cmpl_cb == p_cb))
275 {
276 /* Flush all ACL connections */
277 btm_acl_device_down();
278
279 /* Clear the callback, so application would not hang on reset */
280 btm_db_reset();
281
282 /* Save address of the completion routine, if provided */
283 btm_cb.devcb.p_reset_cmpl_cb = p_cb;
284
285 btm_dev_reset ();
286 }
287 else
288 {
289 /* pass an error to the bad callback, another one was already provided */
290 if (p_cb)
291 {
292 status = BTM_ILLEGAL_VALUE;
293 p_cb (&status);
294 }
295 }
296 }
297
298
299 /*******************************************************************************
300 **
301 ** Function BTM_IsDeviceUp
302 **
303 ** Description This function is called to check if the device is up.
304 **
305 ** Returns TRUE if device is up, else FALSE
306 **
307 *******************************************************************************/
BTM_IsDeviceUp(void)308 BOOLEAN BTM_IsDeviceUp (void)
309 {
310 return ((BOOLEAN) (btm_cb.devcb.state == BTM_DEV_STATE_READY));
311 }
312
313 /*******************************************************************************
314 **
315 ** Function BTM_SetAfhChannels
316 **
317 ** Description This function is called disable channels
318 **
319 ** Returns tBTM_STATUS
320 **
321 *******************************************************************************/
BTM_SetAfhChannels(UINT8 first,UINT8 last)322 tBTM_STATUS BTM_SetAfhChannels (UINT8 first, UINT8 last)
323 {
324 BTM_TRACE_API4 ("BTM_SetAfhChannels first: %d (%d) last: %d (%d)",
325 first, btm_cb.first_disabled_channel, last,
326 btm_cb.last_disabled_channel);
327
328 /* Make sure the local device supports the feature before sending */
329 if ((!HCI_LMP_AFH_CAP_MASTR_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) &&
330 (!HCI_LMP_AFH_CLASS_SLAVE_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) &&
331 (!HCI_LMP_AFH_CLASS_MASTR_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])))
332 return (BTM_MODE_UNSUPPORTED);
333
334 if (!BTM_IsDeviceUp())
335 return (BTM_WRONG_MODE);
336
337 if ((btm_cb.first_disabled_channel != first)
338 || (btm_cb.last_disabled_channel != last))
339 {
340 if (btsnd_hcic_set_afh_channels (first, last))
341 {
342 btm_cb.first_disabled_channel = first;
343 btm_cb.last_disabled_channel = last;
344 }
345 else
346 return (BTM_NO_RESOURCES);
347 }
348 return (BTM_SUCCESS);
349 }
350
351 /*******************************************************************************
352 **
353 ** Function BTM_SetAfhChannelAssessment
354 **
355 ** Description This function is called to set the channel assessment mode on or off
356 **
357 ** Returns none
358 **
359 *******************************************************************************/
BTM_SetAfhChannelAssessment(BOOLEAN enable_or_disable)360 tBTM_STATUS BTM_SetAfhChannelAssessment (BOOLEAN enable_or_disable)
361 {
362 /* whatever app wants if device is not 1.2 scan type should be STANDARD */
363 if (!HCI_LMP_AFH_CAP_SLAVE_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
364 return (BTM_MODE_UNSUPPORTED);
365
366 if (!btsnd_hcic_write_afh_channel_assessment_mode (enable_or_disable))
367 return (BTM_NO_RESOURCES);
368
369 return (BTM_SUCCESS);
370 }
371
372 /*******************************************************************************
373 **
374 ** Function BTM_ContinueReset
375 **
376 ** Description This function is called by the application to continue
377 ** initialization after the application has completed its
378 ** vendor specific sequence. It is only used when
379 ** BTM_APP_DEV_INIT is defined in target.h.
380 **
381 ** Returns void
382 **
383 *******************************************************************************/
BTM_ContinueReset(void)384 void BTM_ContinueReset (void)
385 {
386 #ifdef BTM_APP_DEV_INIT
387 btm_continue_reset();
388 #endif
389 }
390
391 /*******************************************************************************
392 **
393 ** Function btm_dev_reset
394 **
395 ** Description Local function called to send a reset command
396 **
397 ** Returns void
398 **
399 *******************************************************************************/
btm_dev_reset(void)400 static void btm_dev_reset (void)
401 {
402 btm_cb.devcb.state = BTM_DEV_STATE_WAIT_RESET_CMPLT;
403
404 /* flush out the command complete queue and command transmit queue */
405 btu_hcif_flush_cmd_queue();
406
407 /* Start reset timer. When timer expires we will send first command */
408 /* from the setup sequence */
409
410 btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL,
411 BTM_DEV_RESET_TIMEOUT);
412 btsnd_hcic_reset (LOCAL_BR_EDR_CONTROLLER_ID);
413 }
414
415
416 /*******************************************************************************
417 **
418 ** Function btm_get_hci_buf_size
419 **
420 ** Description Local function called to send a read buffer size command
421 **
422 ** Returns void
423 **
424 *******************************************************************************/
btm_get_hci_buf_size(void)425 void btm_get_hci_buf_size (void)
426 {
427
428 btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
429
430 /* Send a Read Buffer Size message to the Host Controller. */
431 btsnd_hcic_read_buffer_size ();
432
433 }
434 #if BLE_INCLUDED == TRUE
435 /*******************************************************************************
436 **
437 ** Function btm_read_ble_wl_size
438 **
439 ** Description Local function called to send a read BLE buffer size command
440 **
441 ** Returns void
442 **
443 *******************************************************************************/
btm_read_ble_wl_size(void)444 void btm_read_ble_wl_size(void)
445 {
446 BTM_TRACE_DEBUG0("btm_read_ble_wl_size ");
447 btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
448
449 /* Send a Read Buffer Size message to the Host Controller. */
450 btsnd_hcic_ble_read_white_list_size();
451 }
452 /*******************************************************************************
453 **
454 ** Function btm_get_ble_buffer_size
455 **
456 ** Description Local function called to send a read BLE buffer size command
457 **
458 ** Returns void
459 **
460 *******************************************************************************/
btm_get_ble_buffer_size(void)461 void btm_get_ble_buffer_size(void)
462 {
463 BTM_TRACE_DEBUG0("btm_get_ble_buffer_size ");
464 btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
465
466 /* Send a Read Buffer Size message to the Host Controller. */
467 btsnd_hcic_ble_read_buffer_size ();
468 }
469
470 /*******************************************************************************
471 **
472 ** Function btm_read_ble_local_supported_features
473 **
474 ** Description Local function called to send a read BLE local supported
475 ** features command
476 **
477 ** Returns void
478 **
479 *******************************************************************************/
btm_read_ble_local_supported_features(void)480 static void btm_read_ble_local_supported_features(void)
481 {
482 BTM_TRACE_DEBUG0("btm_read_ble_local_supported_features ");
483 btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
484
485 /* Send a Read Local Supported Features message to the Host Controller. */
486 btsnd_hcic_ble_read_local_spt_feat ();
487 }
488 #endif
489 /*******************************************************************************
490 **
491 ** Function btm_get_local_version
492 **
493 ** Description Local function called to send a read local version to controller
494 **
495 ** Returns void
496 **
497 *******************************************************************************/
btm_get_local_version(void)498 void btm_get_local_version (void)
499 {
500
501 btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
502
503 /* Send a Read Local Version message to the Host Controller. */
504 btsnd_hcic_read_local_ver (LOCAL_BR_EDR_CONTROLLER_ID);
505 btsnd_hcic_read_bd_addr ();
506
507 #if BTM_PWR_MGR_INCLUDED == TRUE
508 btm_pm_reset();
509 #endif
510
511 }
512
513 /*******************************************************************************
514 **
515 ** Function btm_read_local_supported_cmds
516 **
517 ** Description Local function called to send a read local supported commands
518 **
519 ** Returns void
520 **
521 *******************************************************************************/
btm_read_local_supported_cmds(UINT8 local_controller_id)522 static void btm_read_local_supported_cmds (UINT8 local_controller_id)
523 {
524 BTM_TRACE_DEBUG0("Start reading local supported commands");
525
526 btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
527
528 btsnd_hcic_read_local_supported_cmds(local_controller_id);
529 }
530
531 /*******************************************************************************
532 **
533 ** Function btm_get_local_features
534 **
535 ** Description Local function called to send a read local features
536 **
537 ** Returns void
538 **
539 *******************************************************************************/
btm_get_local_features(void)540 static void btm_get_local_features (void)
541 {
542 /* If this BT controller supports Read Extended Feature */
543 if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
544 {
545 btm_get_local_ext_features(HCI_EXT_FEATURES_PAGE_0);
546 }
547 /* else, if this is a very old BT controller */
548 else
549 {
550 btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
551
552 /* Just read the basic features (legacy HCI command) */
553 btsnd_hcic_read_local_features ();
554 }
555 }
556
557 /*******************************************************************************
558 **
559 ** Function btm_get_local_ext_features
560 **
561 ** Description Local function called to send a read local extended features
562 **
563 ** Returns void
564 **
565 *******************************************************************************/
btm_get_local_ext_features(UINT8 page_number)566 static void btm_get_local_ext_features (UINT8 page_number)
567 {
568 btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
569
570 btsnd_hcic_read_local_ext_features(page_number);
571 }
572
573 /*******************************************************************************
574 **
575 ** Function btm_dev_timeout
576 **
577 ** Description This function is called when a timer list entry expires.
578 **
579 ** Returns void
580 **
581 *******************************************************************************/
btm_dev_timeout(TIMER_LIST_ENT * p_tle)582 void btm_dev_timeout (TIMER_LIST_ENT *p_tle)
583 {
584 TIMER_PARAM_TYPE timer_type = (TIMER_PARAM_TYPE)p_tle->param;
585
586 if ((timer_type & TT_DEV_RESET_MASK) == TT_DEV_RESET)
587 {
588 /* Call device reset as long as there is timeout*/
589 btm_dev_reset();
590 }
591 else if (timer_type == (TIMER_PARAM_TYPE)TT_DEV_RLN)
592 {
593 tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_rln_cmpl_cb;
594
595 btm_cb.devcb.p_rln_cmpl_cb = NULL;
596
597 if (p_cb)
598 (*p_cb)((void *) NULL);
599 }
600 }
601
602 /*******************************************************************************
603 **
604 ** Function btm_reset_complete
605 **
606 ** Description This function is called when command complete for HCI_Reset
607 ** is received. It does not make sense to send next command
608 ** because device is resetting after command complete is
609 ** received. Just start timer and set required state.
610 **
611 ** Returns void
612 **
613 *******************************************************************************/
btm_reset_complete(void)614 void btm_reset_complete (void)
615 {
616 int devinx;
617
618 BTM_TRACE_EVENT0 ("btm_reset_complete");
619
620 /* Handle if btm initiated the reset */
621 if (btm_cb.devcb.state == BTM_DEV_STATE_WAIT_RESET_CMPLT)
622 {
623 /* Tell L2CAP that all connections are gone */
624 l2cu_device_reset ();
625
626 /* Clear current security state */
627 for (devinx = 0; devinx < BTM_SEC_MAX_DEVICE_RECORDS; devinx++)
628 {
629 btm_cb.sec_dev_rec[devinx].sec_state = BTM_SEC_STATE_IDLE;
630 }
631
632 /* After the reset controller should restore all parameters to defaults. */
633 btm_cb.btm_inq_vars.inq_counter = 1;
634 btm_cb.btm_inq_vars.inq_scan_window = HCI_DEF_INQUIRYSCAN_WINDOW;
635 btm_cb.btm_inq_vars.inq_scan_period = HCI_DEF_INQUIRYSCAN_INTERVAL;
636 btm_cb.btm_inq_vars.inq_scan_type = HCI_DEF_SCAN_TYPE;
637
638 btm_cb.btm_inq_vars.page_scan_window = HCI_DEF_PAGESCAN_WINDOW;
639 btm_cb.btm_inq_vars.page_scan_period = HCI_DEF_PAGESCAN_INTERVAL;
640 btm_cb.btm_inq_vars.page_scan_type = HCI_DEF_SCAN_TYPE;
641
642 #if (BTM_AFTER_RESET_TIMEOUT > 0)
643 btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL,
644 BTM_AFTER_RESET_TIMEOUT);
645 #else
646 btm_cb.devcb.state = BTM_DEV_STATE_WAIT_AFTER_RESET;
647 btm_after_reset_hold_complete();
648 #endif
649
650 #if (BLE_INCLUDED == TRUE)
651 btm_cb.ble_ctr_cb.conn_state = BLE_CONN_IDLE;
652 btm_cb.ble_ctr_cb.bg_dev_num = 0;
653 btm_cb.ble_ctr_cb.bg_conn_type = BTM_BLE_CONN_NONE;
654 btm_cb.ble_ctr_cb.p_select_cback = NULL;
655 memset(&btm_cb.ble_ctr_cb.bg_dev_list, 0, (sizeof(tBTM_LE_BG_CONN_DEV)*BTM_BLE_MAX_BG_CONN_DEV_NUM));
656 gatt_reset_bgdev_list();
657 #endif
658 }
659 }
660
661 /*******************************************************************************
662 **
663 ** Function btm_continue_reset
664 **
665 ** Description This function is called when wait period expired after
666 ** device reset or called by the application to continue
667 ** initialization after the application has completed its
668 ** vendor specific sequence.
669 **
670 ** Returns void
671 **
672 *******************************************************************************/
btm_continue_reset(void)673 void btm_continue_reset (void)
674 {
675
676 /* Reinitialize the default class of device */
677 #if BTM_INTERNAL_BB == TRUE
678 btsnd_hcic_read_bd_addr ();
679 #if BTM_PWR_MGR_INCLUDED == TRUE
680 btm_pm_reset();
681 #endif
682 #endif
683
684 btm_get_hci_buf_size ();
685
686 /* default device class */
687 BTM_SetDeviceClass((UINT8 *) BTM_INIT_CLASS_OF_DEVICE);
688
689 #if (BTM_MAX_LOC_BD_NAME_LEN > 0) && (BTM_SET_DEV_NAME_UPON_RESET == TRUE)
690 BTM_SetLocalDeviceName(btm_cb.cfg.bd_name);
691 #elif BTM_USE_DEF_LOCAL_NAME == TRUE
692 BTM_SetLocalDeviceName(BTM_DEF_LOCAL_NAME);
693 #endif
694
695 BTM_SetPinType (btm_cb.cfg.pin_type, btm_cb.cfg.pin_code, btm_cb.cfg.pin_code_len);
696 }
697
698 /*******************************************************************************
699 **
700 ** Function btm_after_reset_hold_complete
701 **
702 ** Description This function is called when wait period expired after
703 ** device reset. Continue intitialization
704 **
705 ** Returns void
706 **
707 *******************************************************************************/
btm_after_reset_hold_complete(void)708 void btm_after_reset_hold_complete (void)
709 {
710 #ifdef BTM_APP_DEV_INIT
711 btu_stop_timer(&btm_cb.devcb.reset_timer);
712 BTM_APP_DEV_INIT();
713 #else
714 btm_continue_reset();
715 #endif
716 }
717
718
719 /*******************************************************************************
720 **
721 ** Function btm_read_hci_buf_size_complete
722 **
723 ** Description This function is called when command complete for
724 ** get HCI buffer size is received. Start timer and send
725 ** read local features request
726 **
727 ** Returns void
728 **
729 *******************************************************************************/
btm_read_hci_buf_size_complete(UINT8 * p,UINT16 evt_len)730 void btm_read_hci_buf_size_complete (UINT8 *p, UINT16 evt_len)
731 {
732 UINT8 status;
733 UINT8 lm_sco_buf_size;
734 UINT16 lm_num_acl_bufs;
735 UINT16 lm_num_sco_bufs;
736 UINT16 acl_buf_size;
737
738 STREAM_TO_UINT8 (status, p);
739 if (status == HCI_SUCCESS)
740 {
741 STREAM_TO_UINT16 (btu_cb.hcit_acl_data_size, p);
742 STREAM_TO_UINT8 (lm_sco_buf_size, p);
743 STREAM_TO_UINT16 (lm_num_acl_bufs, p);
744 STREAM_TO_UINT16 (lm_num_sco_bufs, p);
745
746 btu_cb.hcit_acl_pkt_size = btu_cb.hcit_acl_data_size + HCI_DATA_PREAMBLE_SIZE;
747
748 l2c_link_processs_num_bufs (lm_num_acl_bufs);
749
750 #if BTM_ACL_BUF_SIZE > 0
751 acl_buf_size = (BTM_ACL_BUF_SIZE < L2CAP_MTU_SIZE) ? BTM_ACL_BUF_SIZE : L2CAP_MTU_SIZE;
752 #else
753 acl_buf_size = L2CAP_MTU_SIZE;
754 #endif
755 /* Tell the controller what our buffer sizes are. ?? Need SCO info */
756 btsnd_hcic_set_host_buf_size (acl_buf_size, BTM_SCO_HOST_BUF_SIZE, L2CAP_HOST_FC_ACL_BUFS, 10);
757
758 #if L2CAP_HOST_FLOW_CTRL == TRUE
759 btsnd_hcic_set_host_flow_ctrl (HCI_HOST_FLOW_CTRL_ACL_ON);
760 #endif
761 }
762
763 /* Set the device into connectable and/or discoverable mode (if configured to do so) */
764 #if BTM_IS_CONNECTABLE == TRUE
765 (void) BTM_SetConnectability (BTM_CONNECTABLE, BTM_DEFAULT_CONN_WINDOW, BTM_DEFAULT_CONN_INTERVAL);
766 #endif
767
768 #if BTM_IS_DISCOVERABLE == TRUE
769 (void) BTM_SetDiscoverability (BTM_DEFAULT_DISC_MODE, BTM_DEFAULT_DISC_WINDOW, BTM_DEFAULT_DISC_INTERVAL);
770 #endif
771
772 #if BTM_INTERNAL_BB == TRUE
773 {
774 UINT8 buf[9] = BTM_INTERNAL_LOCAL_VER;
775 btm_read_local_version_complete( buf, 9 );
776 }
777 #else
778 btm_get_local_version ();
779 #endif
780 }
781
782 #if (BLE_INCLUDED == TRUE)
783 /*******************************************************************************
784 **
785 ** Function btm_read_ble_buf_size_complete
786 **
787 ** Description This function is called when command complete for
788 ** get HCI buffer size is received. Start timer and send
789 ** read local supported features request
790 **
791 ** Returns void
792 **
793 *******************************************************************************/
btm_read_ble_buf_size_complete(UINT8 * p,UINT16 evt_len)794 void btm_read_ble_buf_size_complete (UINT8 *p, UINT16 evt_len)
795 {
796 UINT8 status;
797 UINT16 lm_num_le_bufs;
798
799 BTM_TRACE_DEBUG0("btm_read_ble_buf_size_complete ");
800 STREAM_TO_UINT8 (status, p);
801 if (status == HCI_SUCCESS)
802 {
803 STREAM_TO_UINT16 (btu_cb.hcit_ble_acl_data_size, p);
804 STREAM_TO_UINT8 (lm_num_le_bufs, p);
805
806 if (btu_cb.hcit_ble_acl_data_size == 0)
807 btu_cb.hcit_ble_acl_data_size = btu_cb.hcit_acl_data_size;
808
809 btu_cb.hcit_ble_acl_pkt_size = btu_cb.hcit_ble_acl_data_size + HCI_DATA_PREAMBLE_SIZE;
810
811 l2c_link_processs_ble_num_bufs (lm_num_le_bufs);
812 }
813
814 btm_read_ble_local_supported_features();
815 }
816
817 /*******************************************************************************
818 **
819 ** Function btm_read_ble_local_supported_features_complete
820 **
821 ** Description This function is called when command complete for
822 ** Read LE Local Supported Features is received. Start timer and send
823 ** read LMP local features request
824 **
825 ** Returns void
826 **
827 *******************************************************************************/
btm_read_ble_local_supported_features_complete(UINT8 * p,UINT16 evt_len)828 void btm_read_ble_local_supported_features_complete (UINT8 *p, UINT16 evt_len)
829 {
830 UINT8 status;
831
832 BTM_TRACE_DEBUG0("btm_read_ble_local_supported_features_complete ");
833
834 btu_stop_timer (&btm_cb.devcb.reset_timer);
835
836 STREAM_TO_UINT8 (status, p);
837 if (status == HCI_SUCCESS)
838 {
839 STREAM_TO_ARRAY(&btm_cb.devcb.local_le_features, p, HCI_FEATURE_BYTES_PER_PAGE);
840 }
841 else
842 {
843 BTM_TRACE_WARNING1 ("btm_read_ble_local_supported_features_complete status = %d", status);
844 }
845
846 #if BTM_INTERNAL_BB == TRUE
847 {
848 UINT8 buf[9] = BTM_INTERNAL_LOCAL_FEA;
849 btm_read_local_features_complete( buf, 9 );
850 }
851 #else
852
853 /* get local feature if BRCM specific feature is not included */
854 btm_reset_ctrlr_complete();
855 #endif
856
857 }
858
859 /*******************************************************************************
860 **
861 ** Function btm_read_white_list_size_complete
862 **
863 ** Description This function read the current white list size.
864 *******************************************************************************/
btm_read_white_list_size_complete(UINT8 * p,UINT16 evt_len)865 void btm_read_white_list_size_complete(UINT8 *p, UINT16 evt_len)
866 {
867 UINT8 status;
868
869 BTM_TRACE_DEBUG0("btm_read_white_list_size_complete ");
870 STREAM_TO_UINT8 (status, p);
871
872 if (status == HCI_SUCCESS)
873 {
874 STREAM_TO_UINT8(btm_cb.ble_ctr_cb.max_filter_entries, p);
875 btm_cb.ble_ctr_cb.num_empty_filter = btm_cb.ble_ctr_cb.max_filter_entries;
876 }
877
878 btm_get_ble_buffer_size();
879 }
880
881 #endif
882 /*******************************************************************************
883 **
884 ** Function btm_read_local_version_complete
885 **
886 ** Description This function is called when local BD Addr read complete
887 ** message is received from the HCI.
888 **
889 ** Returns void
890 **
891 *******************************************************************************/
btm_read_local_version_complete(UINT8 * p,UINT16 evt_len)892 void btm_read_local_version_complete (UINT8 *p, UINT16 evt_len)
893 {
894 tBTM_VERSION_INFO *p_vi = &btm_cb.devcb.local_version;
895 UINT8 status;
896
897 #ifdef BTA_PRM_CHECK_FW_VER
898 if(BTA_PRM_CHECK_FW_VER(p))
899 return;
900 #endif
901
902 STREAM_TO_UINT8 (status, p);
903 if (status == HCI_SUCCESS)
904 {
905
906 STREAM_TO_UINT8 (p_vi->hci_version, p);
907 STREAM_TO_UINT16 (p_vi->hci_revision, p);
908 STREAM_TO_UINT8 (p_vi->lmp_version, p);
909 STREAM_TO_UINT16 (p_vi->manufacturer, p);
910 STREAM_TO_UINT16 (p_vi->lmp_subversion, p);
911 }
912
913 if (p_vi->hci_version >= HCI_PROTO_VERSION_1_2)
914 {
915 btm_read_local_supported_cmds(LOCAL_BR_EDR_CONTROLLER_ID);
916 }
917 else
918 {
919 btm_get_local_features ();
920 }
921 }
922
923 /*******************************************************************************
924 **
925 ** Function btm_decode_ext_features_page
926 **
927 ** Description This function is decodes a features page.
928 **
929 ** Returns void
930 **
931 *******************************************************************************/
btm_decode_ext_features_page(UINT8 page_number,const UINT8 * p_features)932 static void btm_decode_ext_features_page (UINT8 page_number, const UINT8 *p_features)
933 {
934 UINT8 last;
935 UINT8 first;
936
937 BTM_TRACE_DEBUG1 ("btm_decode_ext_features_page page: %d", page_number);
938 switch (page_number)
939 {
940 /* Extended (Legacy) Page 0 */
941 case HCI_EXT_FEATURES_PAGE_0:
942
943 /* Create ACL supported packet types mask */
944 btm_cb.btm_acl_pkt_types_supported = (BTM_ACL_PKT_TYPES_MASK_DH1 +
945 BTM_ACL_PKT_TYPES_MASK_DM1);
946
947 if (HCI_3_SLOT_PACKETS_SUPPORTED(p_features))
948 btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH3 +
949 BTM_ACL_PKT_TYPES_MASK_DM3);
950
951 if (HCI_5_SLOT_PACKETS_SUPPORTED(p_features))
952 btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH5 +
953 BTM_ACL_PKT_TYPES_MASK_DM5);
954
955 /* _NO_X_DXX masks are reserved before ver 2.0.
956 Set them only for later versions of controller */
957 if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
958 {
959 /* Add in EDR related ACL types */
960 if (!HCI_EDR_ACL_2MPS_SUPPORTED(p_features))
961 {
962 btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 +
963 BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
964 BTM_ACL_PKT_TYPES_MASK_NO_2_DH5);
965 }
966
967 if (!HCI_EDR_ACL_3MPS_SUPPORTED(p_features))
968 {
969 btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 +
970 BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 +
971 BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
972 }
973
974 /* Check to see if 3 and 5 slot packets are available */
975 if (HCI_EDR_ACL_2MPS_SUPPORTED(p_features) ||
976 HCI_EDR_ACL_3MPS_SUPPORTED(p_features))
977 {
978 if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p_features))
979 btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
980 BTM_ACL_PKT_TYPES_MASK_NO_3_DH3);
981
982 if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p_features))
983 btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 +
984 BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
985 }
986 }
987
988 BTM_TRACE_DEBUG1("Local supported ACL packet types: 0x%04x",
989 btm_cb.btm_acl_pkt_types_supported);
990
991 /* Create (e)SCO supported packet types mask */
992 btm_cb.btm_sco_pkt_types_supported = 0;
993 #if BTM_SCO_INCLUDED == TRUE
994 btm_cb.sco_cb.esco_supported = FALSE;
995 #endif
996 if (HCI_SCO_LINK_SUPPORTED(p_features))
997 {
998 btm_cb.btm_sco_pkt_types_supported = BTM_SCO_PKT_TYPES_MASK_HV1;
999
1000 if (HCI_HV2_PACKETS_SUPPORTED(p_features))
1001 btm_cb.btm_sco_pkt_types_supported |= BTM_SCO_PKT_TYPES_MASK_HV2;
1002
1003 if (HCI_HV3_PACKETS_SUPPORTED(p_features))
1004 btm_cb.btm_sco_pkt_types_supported |= BTM_SCO_PKT_TYPES_MASK_HV3;
1005 }
1006
1007 if (HCI_ESCO_EV3_SUPPORTED(p_features))
1008 btm_cb.btm_sco_pkt_types_supported |= BTM_SCO_PKT_TYPES_MASK_EV3;
1009
1010 if (HCI_ESCO_EV4_SUPPORTED(p_features))
1011 btm_cb.btm_sco_pkt_types_supported |= BTM_SCO_PKT_TYPES_MASK_EV4;
1012
1013 if (HCI_ESCO_EV5_SUPPORTED(p_features))
1014 btm_cb.btm_sco_pkt_types_supported |= BTM_SCO_PKT_TYPES_MASK_EV5;
1015 #if BTM_SCO_INCLUDED == TRUE
1016 if (btm_cb.btm_sco_pkt_types_supported & BTM_ESCO_LINK_ONLY_MASK)
1017 {
1018 btm_cb.sco_cb.esco_supported = TRUE;
1019
1020 /* Add in EDR related eSCO types */
1021 if (HCI_EDR_ESCO_2MPS_SUPPORTED(p_features))
1022 {
1023 if (!HCI_3_SLOT_EDR_ESCO_SUPPORTED(p_features))
1024 btm_cb.btm_sco_pkt_types_supported |= BTM_SCO_PKT_TYPES_MASK_NO_2_EV5;
1025 }
1026 else
1027 {
1028 btm_cb.btm_sco_pkt_types_supported |= (BTM_SCO_PKT_TYPES_MASK_NO_2_EV3 +
1029 BTM_SCO_PKT_TYPES_MASK_NO_2_EV5);
1030 }
1031
1032 if (HCI_EDR_ESCO_3MPS_SUPPORTED(p_features))
1033 {
1034 if (!HCI_3_SLOT_EDR_ESCO_SUPPORTED(p_features))
1035 btm_cb.btm_sco_pkt_types_supported |= BTM_SCO_PKT_TYPES_MASK_NO_3_EV5;
1036 }
1037 else
1038 {
1039 btm_cb.btm_sco_pkt_types_supported |= (BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 +
1040 BTM_SCO_PKT_TYPES_MASK_NO_3_EV5);
1041 }
1042 }
1043 #endif
1044
1045 BTM_TRACE_DEBUG1("Local supported SCO packet types: 0x%04x",
1046 btm_cb.btm_sco_pkt_types_supported);
1047
1048 /* Create Default Policy Settings */
1049 if (HCI_SWITCH_SUPPORTED(p_features))
1050 btm_cb.btm_def_link_policy |= HCI_ENABLE_MASTER_SLAVE_SWITCH;
1051 else
1052 btm_cb.btm_def_link_policy &= ~HCI_ENABLE_MASTER_SLAVE_SWITCH;
1053
1054 if (HCI_HOLD_MODE_SUPPORTED(p_features))
1055 btm_cb.btm_def_link_policy |= HCI_ENABLE_HOLD_MODE;
1056 else
1057 btm_cb.btm_def_link_policy &= ~HCI_ENABLE_HOLD_MODE;
1058
1059 if (HCI_SNIFF_MODE_SUPPORTED(p_features))
1060 btm_cb.btm_def_link_policy |= HCI_ENABLE_SNIFF_MODE;
1061 else
1062 btm_cb.btm_def_link_policy &= ~HCI_ENABLE_SNIFF_MODE;
1063
1064 if (HCI_PARK_MODE_SUPPORTED(p_features))
1065 btm_cb.btm_def_link_policy |= HCI_ENABLE_PARK_MODE;
1066 else
1067 btm_cb.btm_def_link_policy &= ~HCI_ENABLE_PARK_MODE;
1068
1069 btm_sec_dev_reset ();
1070 #if ((BTM_EIR_SERVER_INCLUDED == TRUE)||(BTM_EIR_CLIENT_INCLUDED == TRUE))
1071 if (HCI_LMP_INQ_RSSI_SUPPORTED(p_features))
1072 {
1073 if (HCI_EXT_INQ_RSP_SUPPORTED(p_features))
1074 BTM_SetInquiryMode (BTM_INQ_RESULT_EXTENDED);
1075 else
1076 BTM_SetInquiryMode (BTM_INQ_RESULT_WITH_RSSI);
1077 }
1078 #else
1079 if (HCI_LMP_INQ_RSSI_SUPPORTED(p_features))
1080 BTM_SetInquiryMode (BTM_INQ_RESULT_WITH_RSSI);
1081 #endif
1082 #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
1083 if( HCI_NON_FLUSHABLE_PB_SUPPORTED(p_features))
1084 l2cu_set_non_flushable_pbf(TRUE);
1085 else
1086 l2cu_set_non_flushable_pbf(FALSE);
1087 #endif
1088 BTM_SetPageScanType (BTM_DEFAULT_SCAN_TYPE);
1089 BTM_SetInquiryScanType (BTM_DEFAULT_SCAN_TYPE);
1090
1091 break;
1092
1093 /* Extended Page 1 */
1094 case HCI_EXT_FEATURES_PAGE_1:
1095 /* Nothing to do for page 1 */
1096 break;
1097
1098 /* Extended Page 2 */
1099 case HCI_EXT_FEATURES_PAGE_2:
1100 /* Nothing to do for page 2 */
1101 break;
1102
1103 default:
1104 BTM_TRACE_ERROR1("btm_decode_ext_features_page page=%d unknown", page_number);
1105 break;
1106 }
1107 }
1108
1109 /*******************************************************************************
1110 **
1111 ** Function btm_reset_ctrlr_complete
1112 **
1113 ** Description This is the last step of BR/EDR controller startup sequence.
1114 **
1115 ** Returns void
1116 **
1117 *******************************************************************************/
btm_reset_ctrlr_complete()1118 void btm_reset_ctrlr_complete ()
1119 {
1120 tBTM_DEVCB *p_devcb = &btm_cb.devcb;
1121 tBTM_CMPL_CB *p_cb = p_devcb->p_reset_cmpl_cb;
1122 BOOLEAN found = FALSE;
1123 UINT8 i, j, max_page_number;
1124
1125 btu_stop_timer (&btm_cb.devcb.reset_timer);
1126
1127 /* find the highest feature page number which contains non-zero bits */
1128 for (i = HCI_EXT_FEATURES_PAGE_MAX; i >= 0; i--)
1129 {
1130 for (j = 0; j < HCI_FEATURE_BYTES_PER_PAGE; j++)
1131 {
1132 if (p_devcb->local_lmp_features[i][j] != 0)
1133 {
1134 found = TRUE;
1135 break;
1136 }
1137 }
1138 if (found || !i)
1139 {
1140 break;
1141 }
1142 }
1143
1144 if (!found)
1145 BTM_TRACE_WARNING0 ("btm_reset_ctrlr_complete: NONE of local controller features is set");
1146
1147 max_page_number = i;
1148
1149 BTM_TRACE_DEBUG1 ("btm_reset_ctrlr_complete: max_page_number: %d", max_page_number);
1150
1151 /*
1152 * Set State to Ready (needs to be done before btm_decode_ext_features_page
1153 * to allow it to send some HCI configuration commands)
1154 */
1155 p_devcb->state = BTM_DEV_STATE_READY;
1156
1157 /* For every received/saved feature page */
1158 for (i = 0; i <= max_page_number; i++)
1159 {
1160 /* Decode the saved Feature Page */
1161 btm_decode_ext_features_page(i, p_devcb->local_lmp_features[i]);
1162 }
1163
1164 /* If there was a callback address for reset complete, reset it */
1165 p_devcb->p_reset_cmpl_cb = NULL;
1166
1167 /* If anyone wants device status notifications, give him one */
1168 btm_report_device_status(BTM_DEV_STATUS_UP);
1169
1170 /* Reset sequence is complete. If this was an application originated */
1171 /* reset, tell him its done. */
1172 if (p_cb)
1173 (*p_cb)((void *) NULL);
1174 }
1175
1176 /*******************************************************************************
1177 **
1178 ** Function btm_issue_host_support_for_lmp_features
1179 **
1180 ** Description This function:
1181 ** - issues commands to set host supported LMP features (one at
1182 ** a time);
1183 ** - after this is done it issues command to re-read LMP features
1184 ** page 1;
1185 ** - after this is done it calls the last step of BR/EDR
1186 ** controller startup sequence.
1187 **
1188 ** Returns void
1189 **
1190 *******************************************************************************/
btm_issue_host_support_for_lmp_features(void)1191 static void btm_issue_host_support_for_lmp_features (void)
1192 {
1193 BTM_TRACE_DEBUG1("btm_issue_host_support_for_lmp_features lmp_features_host_may_support: 0x%02x", btm_cb.devcb.lmp_features_host_may_support);
1194
1195 if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SSP)
1196 {
1197 btsnd_hcic_write_simple_pairing_mode(HCI_SP_MODE_ENABLED);
1198 return;
1199 }
1200
1201 #if (BLE_INCLUDED == TRUE)
1202 if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_LE)
1203 {
1204 if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SIMULT_BR_LE)
1205 {
1206 /* At the moment the host can't work simultaneously with BR/EDR and LE */
1207 btsnd_hcic_ble_write_host_supported(BTM_BLE_HOST_SUPPORT, 0);
1208 }
1209 else
1210 {
1211 btsnd_hcic_ble_write_host_supported(BTM_BLE_HOST_SUPPORT, 0);
1212 }
1213 return;
1214 }
1215 #endif
1216
1217 if (btm_cb.devcb.lmp_features_host_may_support & BTM_RE_READ_1ST_PAGE)
1218 {
1219 btm_get_local_ext_features(HCI_EXT_FEATURES_PAGE_1);
1220 return;
1221 }
1222
1223 if (!btm_cb.devcb.lmp_features_host_may_support)
1224 {
1225 #if BLE_INCLUDED == TRUE
1226 if (HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1]))
1227 {
1228 btm_read_ble_wl_size();
1229 }
1230 else
1231 #elif BTM_INTERNAL_BB == TRUE
1232 {
1233 UINT8 buf[9] = BTM_INTERNAL_LOCAL_FEA;
1234 btm_read_local_features_complete( buf, 9 );
1235 }
1236 #endif
1237 {
1238 btm_reset_ctrlr_complete();
1239 }
1240 return;
1241 }
1242
1243 BTM_TRACE_ERROR2("%s lmp_features_host_may_support: 0x%02x. This is unexpected.",__FUNCTION__,
1244 btm_cb.devcb.lmp_features_host_may_support);
1245 }
1246
1247 /*******************************************************************************
1248 **
1249 ** Function btm_set_lmp_features_host_may_support
1250 **
1251 ** Description This function is called after all LMP features provided by
1252 ** controller are read. It sets the mask that indicates LMP
1253 ** features the host may support based on LMP features supported
1254 ** by controller.
1255 ** Example:
1256 ** Host may set SSP (host support) bit only if SSP (controller
1257 ** support) bit is set by controller.
1258 **
1259 ** Returns void
1260 **
1261 *******************************************************************************/
btm_set_lmp_features_host_may_support(UINT8 max_page_number)1262 static void btm_set_lmp_features_host_may_support (UINT8 max_page_number)
1263 {
1264 btm_cb.devcb.lmp_features_host_may_support = 0;
1265
1266 /* LMP page 0 is always read */
1267 if (HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
1268 {
1269 /* host may support SSP */
1270 btm_cb.devcb.lmp_features_host_may_support |= BTM_HOST_MAY_SUPP_SSP;
1271 }
1272
1273 #if (BLE_INCLUDED == TRUE)
1274 if (HCI_LE_SPT_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
1275 {
1276 /* host may support LE */
1277 btm_cb.devcb.lmp_features_host_may_support |= BTM_HOST_MAY_SUPP_LE;
1278
1279 if (HCI_SIMUL_LE_BREDR_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
1280 {
1281 /* host may support BR/EDR and LE simultaneously */
1282 btm_cb.devcb.lmp_features_host_may_support |= BTM_HOST_MAY_SUPP_SIMULT_BR_LE;
1283 }
1284 }
1285 #endif
1286
1287 if (max_page_number >= HCI_EXT_FEATURES_PAGE_1)
1288 {
1289 /* nothing yet for HCI_EXT_FEATURES_PAGE_1 */
1290 }
1291
1292 if (max_page_number >= HCI_EXT_FEATURES_PAGE_1)
1293 {
1294 /* nothing yet for HCI_EXT_FEATURES_PAGE_2 */
1295 }
1296
1297 if (btm_cb.devcb.lmp_features_host_may_support)
1298 btm_cb.devcb.lmp_features_host_may_support |= BTM_RE_READ_1ST_PAGE;
1299 }
1300
1301 /*******************************************************************************
1302 **
1303 ** Function btm_read_all_lmp_features_complete
1304 **
1305 ** Description This function is called after all LMP features provided by
1306 ** controller are read.
1307 ** It works with controller supported LMP features which host
1308 ** may support too.
1309 **
1310 ** Returns void
1311 **
1312 *******************************************************************************/
btm_read_all_lmp_features_complete(UINT8 max_page_number)1313 static void btm_read_all_lmp_features_complete (UINT8 max_page_number)
1314 {
1315 btm_set_lmp_features_host_may_support(max_page_number);
1316
1317 btm_issue_host_support_for_lmp_features();
1318 }
1319
1320 /*******************************************************************************
1321 **
1322 ** Function btm_read_local_features_complete
1323 **
1324 ** Description This function is called when local supported features read
1325 ** is complete.
1326 **
1327 ** Returns void
1328 **
1329 *******************************************************************************/
btm_read_local_features_complete(UINT8 * p,UINT16 evt_len)1330 void btm_read_local_features_complete (UINT8 *p, UINT16 evt_len)
1331 {
1332 tBTM_DEVCB *p_devcb = &btm_cb.devcb;
1333 UINT8 status;
1334
1335 btu_stop_timer (&p_devcb->reset_timer);
1336
1337 STREAM_TO_UINT8 (status, p);
1338 if (status == HCI_SUCCESS)
1339 {
1340 /* Save the Feature Page 0 */
1341 STREAM_TO_ARRAY(p_devcb->local_lmp_features[0],
1342 p, HCI_FEATURE_BYTES_PER_PAGE);
1343
1344 if ((HCI_LMP_EXTENDED_SUPPORTED(p_devcb->local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) &&
1345 (HCI_READ_LOCAL_EXT_FEATURES_SUPPORTED(p_devcb->supported_cmds)))
1346 {
1347 /* if local controller has extended features and supports
1348 **HCI_Read_Local_Extended_Features command,
1349 ** then start reading these feature starting with extended features page 1 */
1350 BTM_TRACE_DEBUG0 ("Start reading local extended features");
1351 btm_get_local_ext_features(HCI_EXT_FEATURES_PAGE_1);
1352 }
1353 else
1354 {
1355 btm_read_all_lmp_features_complete (HCI_EXT_FEATURES_PAGE_0);
1356 }
1357 }
1358 }
1359
1360 /*******************************************************************************
1361 **
1362 ** Function btm_read_local_ext_features_complete
1363 **
1364 ** Description This function is called when read local extended features
1365 ** command complete message is received from the HCI.
1366 **
1367 ** Returns void
1368 **
1369 *******************************************************************************/
btm_read_local_ext_features_complete(UINT8 * p,UINT16 evt_len)1370 void btm_read_local_ext_features_complete (UINT8 *p, UINT16 evt_len)
1371 {
1372 tBTM_DEVCB *p_devcb = &btm_cb.devcb;
1373 tBTM_CMPL_CB *p_cb = p_devcb->p_reset_cmpl_cb;
1374 UINT8 status;
1375 UINT8 page_number;
1376 UINT8 page_number_max;
1377
1378 btu_stop_timer (&btm_cb.devcb.reset_timer);
1379
1380 STREAM_TO_UINT8 (status, p);
1381
1382 if (status != HCI_SUCCESS)
1383 {
1384 BTM_TRACE_WARNING1("btm_read_local_ext_features_complete status = 0x%02X", status);
1385 btm_read_all_lmp_features_complete (HCI_EXT_FEATURES_PAGE_0);
1386 return;
1387 }
1388
1389 /* Extract Page number */
1390 STREAM_TO_UINT8 (page_number, p);
1391
1392 /* Extract Page number Max */
1393 STREAM_TO_UINT8 (page_number_max, p);
1394
1395 if (page_number > HCI_EXT_FEATURES_PAGE_MAX)
1396 {
1397 BTM_TRACE_ERROR1("btm_read_local_ext_features_complete page=%d unknown",
1398 page_number);
1399 return;
1400 }
1401
1402 /* Save the extended features Page received */
1403 STREAM_TO_ARRAY(btm_cb.devcb.local_lmp_features[page_number],
1404 p, HCI_FEATURE_BYTES_PER_PAGE);
1405
1406 /* If this is re-read of the 1-st extended page after host supported LMP features are set */
1407 if ((page_number == HCI_EXT_FEATURES_PAGE_1) &&
1408 (btm_cb.devcb.lmp_features_host_may_support == BTM_RE_READ_1ST_PAGE))
1409 {
1410 btm_cb.devcb.lmp_features_host_may_support &= ~BTM_RE_READ_1ST_PAGE;
1411 btm_issue_host_support_for_lmp_features();
1412 return;
1413 }
1414
1415 /* If this is the last page supported by the local BT controller OR */
1416 /* if this is the last page supported by the Host */
1417 if ((page_number == page_number_max) ||
1418 (page_number == HCI_EXT_FEATURES_PAGE_MAX))
1419 {
1420 BTM_TRACE_DEBUG1("BTM reached last extended features page (%d)", page_number);
1421 btm_read_all_lmp_features_complete(page_number);
1422 }
1423 /* Else (another page must be read) */
1424 else
1425 {
1426 /* Read the next features page */
1427 page_number++;
1428 BTM_TRACE_DEBUG1("BTM reads next extended features page (%d)", page_number);
1429 btm_get_local_ext_features(page_number);
1430 }
1431 }
1432
1433 /*******************************************************************************
1434 **
1435 ** Function btm_read_local_supported_cmds_complete
1436 **
1437 ** Description This function is called when local supported commands read
1438 ** is complete.
1439 **
1440 ** Returns void
1441 **
1442 *******************************************************************************/
btm_read_local_supported_cmds_complete(UINT8 * p)1443 void btm_read_local_supported_cmds_complete (UINT8 *p)
1444 {
1445 tBTM_DEVCB *p_devcb = &btm_cb.devcb;
1446 UINT8 status;
1447
1448 btu_stop_timer (&(p_devcb->reset_timer));
1449
1450 STREAM_TO_UINT8 (status, p);
1451 BTM_TRACE_DEBUG1("btm_read_local_supported_cmds_complete status (0x%02x)", status);
1452
1453 if (status == HCI_SUCCESS)
1454 {
1455 /* Save the supported commands bit mask */
1456 STREAM_TO_ARRAY(p_devcb->supported_cmds, p, HCI_NUM_SUPP_COMMANDS_BYTES);
1457 }
1458
1459 btm_get_local_features();
1460 }
1461
1462 /*******************************************************************************
1463 **
1464 ** Function btm_write_simple_paring_mode_complete
1465 **
1466 ** Description This function is called when the command complete message
1467 ** is received from the HCI for the write simple pairing mode
1468 ** command.
1469 **
1470 ** Returns void
1471 **
1472 *******************************************************************************/
btm_write_simple_paring_mode_complete(UINT8 * p)1473 void btm_write_simple_paring_mode_complete (UINT8 *p)
1474 {
1475 UINT8 status;
1476
1477 STREAM_TO_UINT8 (status, p);
1478
1479 if (status != HCI_SUCCESS)
1480 {
1481 BTM_TRACE_WARNING1("btm_write_simple_paring_mode_complete status: 0x%02x", status);
1482 }
1483
1484 if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SSP)
1485 {
1486 btm_cb.devcb.lmp_features_host_may_support &= ~BTM_HOST_MAY_SUPP_SSP;
1487 btm_issue_host_support_for_lmp_features();
1488 }
1489 }
1490
1491 /*******************************************************************************
1492 **
1493 ** Function btm_write_le_host_supported_complete
1494 **
1495 ** Description This function is called when the command complete message
1496 ** is received from the HCI for the write LE host supported
1497 ** command.
1498 **
1499 ** Returns void
1500 **
1501 *******************************************************************************/
btm_write_le_host_supported_complete(UINT8 * p)1502 void btm_write_le_host_supported_complete (UINT8 *p)
1503 {
1504 UINT8 status;
1505
1506 STREAM_TO_UINT8 (status, p);
1507
1508 if (status != HCI_SUCCESS)
1509 {
1510 BTM_TRACE_WARNING1("btm_write_le_host_supported_complete status: 0x%02x", status);
1511 }
1512
1513 if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_LE)
1514 {
1515 btm_cb.devcb.lmp_features_host_may_support &= ~BTM_HOST_MAY_SUPP_LE;
1516 if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SIMULT_BR_LE)
1517 {
1518 btm_cb.devcb.lmp_features_host_may_support &= ~BTM_HOST_MAY_SUPP_SIMULT_BR_LE;
1519 }
1520 btm_issue_host_support_for_lmp_features();
1521 }
1522 }
1523
1524 /*******************************************************************************
1525 **
1526 ** Function btm_get_voice_coding_support
1527 **
1528 ** Description This function is provides a way to get the voice coding schemes
1529 ** supported the device.
1530 **
1531 ** Returns A bit mask - Bit 0 if set indicates CVSD support
1532 ** Bit 1 if set indicates PCM A-law support
1533 ** Bit 2 if set indicates PCM Mu-law support
1534 **
1535 *******************************************************************************/
1536
btm_get_voice_coding_support(void)1537 UINT8 btm_get_voice_coding_support( void )
1538 {
1539 UINT8 code = 0;
1540
1541 if( HCI_LMP_CVSD_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]) ) code |= 0x01 ;
1542 if( HCI_LMP_A_LAW_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]) ) code |= 0x02 ;
1543 if( HCI_LMP_U_LAW_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]) ) code |= 0x04 ;
1544
1545 return code ;
1546 }
1547
1548 /*******************************************************************************
1549 **
1550 ** Function BTM_SetLocalDeviceName
1551 **
1552 ** Description This function is called to set the local device name.
1553 **
1554 ** Returns status of the operation
1555 **
1556 *******************************************************************************/
BTM_SetLocalDeviceName(char * p_name)1557 tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
1558 {
1559 UINT8 *p;
1560
1561 if (!p_name || !p_name[0] || (strlen ((char *)p_name) > BD_NAME_LEN))
1562 return (BTM_ILLEGAL_VALUE);
1563
1564 if (btm_cb.devcb.state == BTM_DEV_STATE_WAIT_RESET_CMPLT ||
1565 btm_cb.devcb.state == BTM_DEV_STATE_WAIT_AFTER_RESET)
1566 return (BTM_DEV_RESET);
1567
1568 #if BTM_MAX_LOC_BD_NAME_LEN > 0
1569 /* Save the device name if local storage is enabled */
1570 p = (UINT8 *)btm_cb.cfg.bd_name;
1571 if (p != (UINT8 *)p_name)
1572 {
1573 BCM_STRNCPY_S(btm_cb.cfg.bd_name, sizeof(btm_cb.cfg.bd_name), p_name, BTM_MAX_LOC_BD_NAME_LEN);
1574 btm_cb.cfg.bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0';
1575 }
1576 #else
1577 p = (UINT8 *)p_name;
1578 #endif
1579
1580 if (btsnd_hcic_change_name(p))
1581 return (BTM_CMD_STARTED);
1582 else
1583 return (BTM_NO_RESOURCES);
1584 }
1585
1586
1587
1588 /*******************************************************************************
1589 **
1590 ** Function BTM_ReadLocalDeviceName
1591 **
1592 ** Description This function is called to read the local device name.
1593 **
1594 ** Returns status of the operation
1595 ** If success, BTM_SUCCESS is returned and p_name points stored
1596 ** local device name
1597 ** If BTM doesn't store local device name, BTM_NO_RESOURCES is
1598 ** is returned and p_name is set to NULL
1599 **
1600 *******************************************************************************/
BTM_ReadLocalDeviceName(char ** p_name)1601 tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name)
1602 {
1603 #if BTM_MAX_LOC_BD_NAME_LEN > 0
1604 *p_name = btm_cb.cfg.bd_name;
1605 return(BTM_SUCCESS);
1606 #else
1607 *p_name = NULL;
1608 return(BTM_NO_RESOURCES);
1609 #endif
1610 }
1611
1612
1613 /*******************************************************************************
1614 **
1615 ** Function BTM_ReadLocalDeviceNameFromController
1616 **
1617 ** Description Get local device name from controller. Do not use cached
1618 ** name (used to get chip-id prior to btm reset complete).
1619 **
1620 ** Returns BTM_CMD_STARTED if successful, otherwise an error
1621 **
1622 *******************************************************************************/
BTM_ReadLocalDeviceNameFromController(tBTM_CMPL_CB * p_rln_cmpl_cback)1623 tBTM_STATUS BTM_ReadLocalDeviceNameFromController (tBTM_CMPL_CB *p_rln_cmpl_cback)
1624 {
1625 /* Check if rln already in progress */
1626 if (btm_cb.devcb.p_rln_cmpl_cb)
1627 return(BTM_NO_RESOURCES);
1628
1629 /* Save callback */
1630 btm_cb.devcb.p_rln_cmpl_cb = p_rln_cmpl_cback;
1631
1632 btsnd_hcic_read_name();
1633 btu_start_timer (&btm_cb.devcb.rln_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT);
1634
1635 return BTM_CMD_STARTED;
1636 }
1637
1638 /*******************************************************************************
1639 **
1640 ** Function btm_read_local_name_complete
1641 **
1642 ** Description This function is called when local name read complete.
1643 ** message is received from the HCI.
1644 **
1645 ** Returns void
1646 **
1647 *******************************************************************************/
btm_read_local_name_complete(UINT8 * p,UINT16 evt_len)1648 void btm_read_local_name_complete (UINT8 *p, UINT16 evt_len)
1649 {
1650 tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_rln_cmpl_cb;
1651 UINT8 status;
1652
1653 btu_stop_timer (&btm_cb.devcb.rln_timer);
1654
1655 /* If there was a callback address for read local name, call it */
1656 btm_cb.devcb.p_rln_cmpl_cb = NULL;
1657
1658 if (p_cb)
1659 {
1660 STREAM_TO_UINT8 (status, p);
1661
1662 if (status == HCI_SUCCESS)
1663 (*p_cb)(p);
1664 else
1665 (*p_cb)(NULL);
1666 }
1667 }
1668
1669
1670 /*******************************************************************************
1671 **
1672 ** Function BTM_GetLocalDeviceAddr
1673 **
1674 ** Description This function is called to read the local device address
1675 **
1676 ** Returns void
1677 ** the local device address is copied into bd_addr
1678 **
1679 *******************************************************************************/
BTM_GetLocalDeviceAddr(BD_ADDR bd_addr)1680 void BTM_GetLocalDeviceAddr (BD_ADDR bd_addr)
1681 {
1682 memcpy (bd_addr, btm_cb.devcb.local_addr, BD_ADDR_LEN);
1683 }
1684
1685 /*******************************************************************************
1686 **
1687 ** Function BTM_ReadLocalDeviceAddr
1688 **
1689 ** Description This function is called to read the local device address
1690 **
1691 ** Returns status of the operation
1692 **
1693 *******************************************************************************/
BTM_ReadLocalDeviceAddr(tBTM_CMPL_CB * p_cb)1694 tBTM_STATUS BTM_ReadLocalDeviceAddr (tBTM_CMPL_CB *p_cb)
1695 {
1696 if(p_cb)
1697 (*p_cb)(btm_cb.devcb.local_addr);
1698
1699 return (BTM_SUCCESS);
1700 }
1701
1702
1703 /*******************************************************************************
1704 **
1705 ** Function btm_read_local_addr_complete
1706 **
1707 ** Description This function is called when local BD Addr read complete
1708 ** message is received from the HCI.
1709 **
1710 ** Returns void
1711 **
1712 *******************************************************************************/
btm_read_local_addr_complete(UINT8 * p,UINT16 evt_len)1713 void btm_read_local_addr_complete (UINT8 *p, UINT16 evt_len)
1714 {
1715 UINT8 status;
1716
1717 STREAM_TO_UINT8 (status, p);
1718
1719 if (status == HCI_SUCCESS)
1720 {
1721 STREAM_TO_BDADDR (btm_cb.devcb.local_addr, p);
1722 }
1723 }
1724
1725
1726 /*******************************************************************************
1727 **
1728 ** Function BTM_ReadLocalVersion
1729 **
1730 ** Description This function is called to read the local device version
1731 **
1732 ** Returns status of the operation
1733 **
1734 *******************************************************************************/
BTM_ReadLocalVersion(tBTM_VERSION_INFO * p_vers)1735 tBTM_STATUS BTM_ReadLocalVersion (tBTM_VERSION_INFO *p_vers)
1736 {
1737 /* Make sure the device has retrieved the info (not being reset) */
1738 if (btm_cb.devcb.state < BTM_DEV_STATE_READY)
1739 return (BTM_DEV_RESET);
1740
1741 *p_vers = btm_cb.devcb.local_version;
1742
1743 return (BTM_SUCCESS);
1744 }
1745
1746
1747
1748
1749 /*******************************************************************************
1750 **
1751 ** Function BTM_SetDeviceClass
1752 **
1753 ** Description This function is called to set the local device class
1754 **
1755 ** Returns status of the operation
1756 **
1757 *******************************************************************************/
BTM_SetDeviceClass(DEV_CLASS dev_class)1758 tBTM_STATUS BTM_SetDeviceClass (DEV_CLASS dev_class)
1759 {
1760 if(!memcmp (btm_cb.devcb.dev_class, dev_class, DEV_CLASS_LEN))
1761 return(BTM_SUCCESS);
1762
1763 memcpy (btm_cb.devcb.dev_class, dev_class, DEV_CLASS_LEN);
1764
1765 if (btm_cb.devcb.state == BTM_DEV_STATE_WAIT_RESET_CMPLT ||
1766 btm_cb.devcb.state == BTM_DEV_STATE_WAIT_AFTER_RESET)
1767 return (BTM_DEV_RESET);
1768
1769 if (!btsnd_hcic_write_dev_class (dev_class))
1770 return (BTM_NO_RESOURCES);
1771
1772 return (BTM_SUCCESS);
1773 }
1774
1775
1776 /*******************************************************************************
1777 **
1778 ** Function BTM_ReadDeviceClass
1779 **
1780 ** Description This function is called to read the local device class
1781 **
1782 ** Returns pointer to the device class
1783 **
1784 *******************************************************************************/
BTM_ReadDeviceClass(void)1785 UINT8 *BTM_ReadDeviceClass (void)
1786 {
1787 return ((UINT8 *)btm_cb.devcb.dev_class);
1788 }
1789
1790
1791 /*******************************************************************************
1792 **
1793 ** Function BTM_ReadLocalFeatures
1794 **
1795 ** Description This function is called to read the local features
1796 **
1797 ** Returns pointer to the local features string
1798 **
1799 *******************************************************************************/
BTM_ReadLocalFeatures(void)1800 UINT8 *BTM_ReadLocalFeatures (void)
1801 {
1802 return (btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]);
1803 }
1804
1805 /*******************************************************************************
1806 **
1807 ** Function BTM_ReadLocalExtendedFeatures
1808 **
1809 ** Description This function is called to read the local extended features
1810 **
1811 ** Returns pointer to the local extended features mask or NULL if bad
1812 ** page
1813 **
1814 *******************************************************************************/
BTM_ReadLocalExtendedFeatures(UINT8 page_number)1815 UINT8 *BTM_ReadLocalExtendedFeatures (UINT8 page_number)
1816 {
1817 if (page_number <= HCI_EXT_FEATURES_PAGE_MAX)
1818 return (btm_cb.devcb.local_lmp_features[page_number]);
1819
1820 BTM_TRACE_ERROR1("Warning: BTM_ReadLocalExtendedFeatures page %d unknown",
1821 page_number);
1822 return NULL;
1823 }
1824
1825 /*******************************************************************************
1826 **
1827 ** Function BTM_ReadBrcmFeatures
1828 **
1829 ** Description This function is called to read the Broadcom specific features
1830 **
1831 ** Returns pointer to the Broadcom features string
1832 **
1833 *******************************************************************************/
BTM_ReadBrcmFeatures(void)1834 UINT8 *BTM_ReadBrcmFeatures (void)
1835 {
1836 return (btm_cb.devcb.brcm_features);
1837 }
1838
1839 /*******************************************************************************
1840 **
1841 ** Function BTM_RegisterForDeviceStatusNotif
1842 **
1843 ** Description This function is called to register for device status
1844 ** change notifications.
1845 **
1846 ** If one registration is already there calling function should
1847 ** save the pointer to the function that is return and
1848 ** call it when processing of the event is complete
1849 **
1850 ** Returns status of the operation
1851 **
1852 *******************************************************************************/
BTM_RegisterForDeviceStatusNotif(tBTM_DEV_STATUS_CB * p_cb)1853 tBTM_DEV_STATUS_CB *BTM_RegisterForDeviceStatusNotif (tBTM_DEV_STATUS_CB *p_cb)
1854 {
1855 tBTM_DEV_STATUS_CB *p_prev = btm_cb.devcb.p_dev_status_cb;
1856
1857 btm_cb.devcb.p_dev_status_cb = p_cb;
1858 return (p_prev);
1859 }
1860
1861 /*******************************************************************************
1862 **
1863 ** Function BTM_VendorSpecificCommand
1864 **
1865 ** Description Send a vendor specific HCI command to the controller.
1866 **
1867 ** Returns
1868 ** BTM_SUCCESS Command sent. Does not expect command complete
1869 ** event. (command cmpl callback param is NULL)
1870 ** BTM_CMD_STARTED Command sent. Waiting for command cmpl event.
1871 **
1872 ** Notes
1873 ** Opcode will be OR'd with HCI_GRP_VENDOR_SPECIFIC.
1874 **
1875 *******************************************************************************/
BTM_VendorSpecificCommand(UINT16 opcode,UINT8 param_len,UINT8 * p_param_buf,tBTM_VSC_CMPL_CB * p_cb)1876 tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode, UINT8 param_len,
1877 UINT8 *p_param_buf, tBTM_VSC_CMPL_CB *p_cb)
1878 {
1879 void *p_buf;
1880
1881 BTM_TRACE_EVENT2 ("BTM: BTM_VendorSpecificCommand: Opcode: 0x%04X, ParamLen: %i.",
1882 opcode, param_len);
1883
1884 /* Allocate a buffer to hold HCI command plus the callback function */
1885 if ((p_buf = GKI_getbuf((UINT16)(sizeof(BT_HDR) + sizeof (tBTM_CMPL_CB *) +
1886 param_len + HCIC_PREAMBLE_SIZE))) != NULL)
1887 {
1888 /* Send the HCI command (opcode will be OR'd with HCI_GRP_VENDOR_SPECIFIC) */
1889 btsnd_hcic_vendor_spec_cmd (p_buf, opcode, param_len, p_param_buf, (void *)p_cb);
1890
1891 /* Return value */
1892 if (p_cb != NULL)
1893 return (BTM_CMD_STARTED);
1894 else
1895 return (BTM_SUCCESS);
1896 }
1897 else
1898 return (BTM_NO_RESOURCES);
1899
1900 }
1901
1902
1903 /*******************************************************************************
1904 **
1905 ** Function btm_vsc_complete
1906 **
1907 ** Description This function is called when local HCI Vendor Specific
1908 ** Command complete message is received from the HCI.
1909 **
1910 ** Returns void
1911 **
1912 *******************************************************************************/
btm_vsc_complete(UINT8 * p,UINT16 opcode,UINT16 evt_len,tBTM_CMPL_CB * p_vsc_cplt_cback)1913 void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
1914 tBTM_CMPL_CB *p_vsc_cplt_cback)
1915 {
1916 tBTM_VSC_CMPL vcs_cplt_params;
1917
1918 /* If there was a callback address for vcs complete, call it */
1919 if (p_vsc_cplt_cback)
1920 {
1921 /* Pass paramters to the callback function */
1922 vcs_cplt_params.opcode = opcode; /* Number of bytes in return info */
1923 vcs_cplt_params.param_len = evt_len; /* Number of bytes in return info */
1924 vcs_cplt_params.p_param_buf = p;
1925 (*p_vsc_cplt_cback)(&vcs_cplt_params); /* Call the VSC complete callback function */
1926 }
1927 }
1928
1929 /*******************************************************************************
1930 **
1931 ** Function BTM_RegisterForVSEvents
1932 **
1933 ** Description This function is called to register/deregister for vendor
1934 ** specific HCI events.
1935 **
1936 ** If is_register=TRUE, then the function will be registered;
1937 ** if is_register=FALSE, then the function will be deregistered.
1938 **
1939 ** Returns BTM_SUCCESS if successful,
1940 ** BTM_BUSY if maximum number of callbacks have already been
1941 ** registered.
1942 **
1943 *******************************************************************************/
BTM_RegisterForVSEvents(tBTM_VS_EVT_CB * p_cb,BOOLEAN is_register)1944 tBTM_STATUS BTM_RegisterForVSEvents (tBTM_VS_EVT_CB *p_cb, BOOLEAN is_register)
1945 {
1946 tBTM_STATUS retval = BTM_SUCCESS;
1947 UINT8 i, free_idx = BTM_MAX_VSE_CALLBACKS;
1948
1949 /* See if callback is already registered */
1950 for (i=0; i<BTM_MAX_VSE_CALLBACKS; i++)
1951 {
1952 if (btm_cb.devcb.p_vend_spec_cb[i] == NULL)
1953 {
1954 /* Found a free slot. Store index */
1955 free_idx = i;
1956 }
1957 else if (btm_cb.devcb.p_vend_spec_cb[i] == p_cb)
1958 {
1959 /* Found callback in lookup table. If deregistering, clear the entry. */
1960 if (is_register == FALSE)
1961 {
1962 btm_cb.devcb.p_vend_spec_cb[i] = NULL;
1963 BTM_TRACE_EVENT0("BTM Deregister For VSEvents is successfully");
1964 }
1965 return (BTM_SUCCESS);
1966 }
1967 }
1968
1969 /* Didn't find callback. Add callback to free slot if registering */
1970 if (is_register)
1971 {
1972 if (free_idx < BTM_MAX_VSE_CALLBACKS)
1973 {
1974 btm_cb.devcb.p_vend_spec_cb[free_idx] = p_cb;
1975 BTM_TRACE_EVENT0("BTM Register For VSEvents is successfully");
1976 }
1977 else
1978 {
1979 /* No free entries available */
1980 BTM_TRACE_ERROR0 ("BTM_RegisterForVSEvents: too many callbacks registered");
1981
1982 retval = BTM_NO_RESOURCES;
1983 }
1984 }
1985
1986 return (retval);
1987 }
1988
1989 /*******************************************************************************
1990 **
1991 ** Function btm_vendor_specific_evt
1992 **
1993 ** Description Process event HCI_VENDOR_SPECIFIC_EVT
1994 **
1995 ** Note: Some controllers do not send command complete, so
1996 ** the callback and busy flag are cleared here also.
1997 **
1998 ** Returns void
1999 **
2000 *******************************************************************************/
btm_vendor_specific_evt(UINT8 * p,UINT8 evt_len)2001 void btm_vendor_specific_evt (UINT8 *p, UINT8 evt_len)
2002 {
2003 UINT8 i;
2004
2005 BTM_TRACE_DEBUG0 ("BTM Event: Vendor Specific event from controller");
2006
2007 for (i=0; i<BTM_MAX_VSE_CALLBACKS; i++)
2008 {
2009 if (btm_cb.devcb.p_vend_spec_cb[i])
2010 (*btm_cb.devcb.p_vend_spec_cb[i])(evt_len, p);
2011 }
2012 }
2013
2014
2015 /*******************************************************************************
2016 **
2017 ** Function BTM_WritePageTimeout
2018 **
2019 ** Description Send HCI Write Page Timeout.
2020 **
2021 ** Returns
2022 ** BTM_SUCCESS Command sent.
2023 ** BTM_NO_RESOURCES If out of resources to send the command.
2024 **
2025 **
2026 *******************************************************************************/
BTM_WritePageTimeout(UINT16 timeout)2027 tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout)
2028 {
2029 BTM_TRACE_EVENT1 ("BTM: BTM_WritePageTimeout: Timeout: %d.", timeout);
2030
2031 /* Send the HCI command */
2032 if (btsnd_hcic_write_page_tout (timeout))
2033 return (BTM_SUCCESS);
2034 else
2035 return (BTM_NO_RESOURCES);
2036 }
2037
2038 /*******************************************************************************
2039 **
2040 ** Function BTM_WriteVoiceSettings
2041 **
2042 ** Description Send HCI Write Voice Settings command.
2043 ** See hcidefs.h for settings bitmask values.
2044 **
2045 ** Returns
2046 ** BTM_SUCCESS Command sent.
2047 ** BTM_NO_RESOURCES If out of resources to send the command.
2048 **
2049 **
2050 *******************************************************************************/
BTM_WriteVoiceSettings(UINT16 settings)2051 tBTM_STATUS BTM_WriteVoiceSettings(UINT16 settings)
2052 {
2053 BTM_TRACE_EVENT1 ("BTM: BTM_WriteVoiceSettings: Settings: 0x%04x.", settings);
2054
2055 /* Send the HCI command */
2056 if (btsnd_hcic_write_voice_settings ((UINT16)(settings & 0x03ff)))
2057 return (BTM_SUCCESS);
2058
2059 return (BTM_NO_RESOURCES);
2060 }
2061
2062 /*******************************************************************************
2063 **
2064 ** Function BTM_EnableTestMode
2065 **
2066 ** Description Send HCI the enable device under test command.
2067 **
2068 ** Note: Controller can only be taken out of this mode by
2069 ** resetting the controller.
2070 **
2071 ** Returns
2072 ** BTM_SUCCESS Command sent.
2073 ** BTM_NO_RESOURCES If out of resources to send the command.
2074 **
2075 **
2076 *******************************************************************************/
BTM_EnableTestMode(void)2077 tBTM_STATUS BTM_EnableTestMode(void)
2078 {
2079 UINT8 cond;
2080
2081 BTM_TRACE_EVENT0 ("BTM: BTM_EnableTestMode");
2082
2083 /* set auto accept connection as this is needed during test mode */
2084 /* Allocate a buffer to hold HCI command */
2085 cond = HCI_DO_AUTO_ACCEPT_CONNECT;
2086 if (!btsnd_hcic_set_event_filter(HCI_FILTER_CONNECTION_SETUP,
2087 HCI_FILTER_COND_NEW_DEVICE,
2088 &cond, sizeof(cond)))
2089 {
2090 return (BTM_NO_RESOURCES);
2091 }
2092
2093 /* put device to connectable mode */
2094 if (!BTM_SetConnectability(BTM_CONNECTABLE, BTM_DEFAULT_CONN_WINDOW,
2095 BTM_DEFAULT_CONN_INTERVAL) == BTM_SUCCESS)
2096 {
2097 return BTM_NO_RESOURCES;
2098 }
2099
2100 /* put device to discoverable mode */
2101 if (!BTM_SetDiscoverability(BTM_GENERAL_DISCOVERABLE, BTM_DEFAULT_DISC_WINDOW,
2102 BTM_DEFAULT_DISC_INTERVAL) == BTM_SUCCESS)
2103 {
2104 return BTM_NO_RESOURCES;
2105 }
2106
2107 /* mask off all of event from controller */
2108 if (!btsnd_hcic_set_event_mask(LOCAL_BR_EDR_CONTROLLER_ID,
2109 (UINT8 *)"\x00\x00\x00\x00\x00\x00\x00\x00"))
2110 {
2111 return BTM_NO_RESOURCES;
2112 }
2113
2114 /* Send the HCI command */
2115 if (btsnd_hcic_enable_test_mode ())
2116 return (BTM_SUCCESS);
2117 else
2118 return (BTM_NO_RESOURCES);
2119 }
2120
2121 /*******************************************************************************
2122 **
2123 ** Function btm_get_hci_version
2124 **
2125 ** Description Local function called to retrieve the current HCI version
2126 **
2127 ** Returns Bluetooth HCI Version returned by the controller
2128 **
2129 *******************************************************************************/
btm_get_hci_version(void)2130 UINT8 btm_get_hci_version (void)
2131 {
2132 return (btm_cb.devcb.local_version.hci_version);
2133 }
2134
2135
2136
2137 /*******************************************************************************
2138 **
2139 ** Function BTM_ReadStoredLinkKey
2140 **
2141 ** Description This function is called to obtain link key for the specified
2142 ** device from the NVRAM storage attached to the Bluetooth
2143 ** controller.
2144 **
2145 ** Parameters: bd_addr - Address of the device
2146 ** p_cb - Call back function to be called to return
2147 ** the results
2148 **
2149 *******************************************************************************/
BTM_ReadStoredLinkKey(BD_ADDR bd_addr,tBTM_CMPL_CB * p_cb)2150 tBTM_STATUS BTM_ReadStoredLinkKey (BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb)
2151 {
2152 BD_ADDR local_bd_addr;
2153 BOOLEAN read_all_flag = FALSE;
2154
2155 /* Check if the previous command is completed */
2156 if (btm_cb.devcb.p_stored_link_key_cmpl_cb)
2157 return (BTM_BUSY);
2158
2159 if (!bd_addr)
2160 {
2161 /* This is to read all the link keys */
2162 read_all_flag = TRUE;
2163
2164 /* We don't care the BD address. Just pass a non zero pointer */
2165 bd_addr = local_bd_addr;
2166 }
2167
2168 BTM_TRACE_EVENT1 ("BTM: BTM_ReadStoredLinkKey: Read_All: %s",
2169 read_all_flag ? "TRUE" : "FALSE");
2170
2171 /* Send the HCI command */
2172 btm_cb.devcb.p_stored_link_key_cmpl_cb = p_cb;
2173 if (btsnd_hcic_read_stored_key (bd_addr, read_all_flag))
2174 return (BTM_SUCCESS);
2175 else
2176 return (BTM_NO_RESOURCES);
2177
2178 }
2179
2180
2181 /*******************************************************************************
2182 **
2183 ** Function BTM_WriteStoredLinkKey
2184 **
2185 ** Description This function is called to write link keys for the specified
2186 ** device addresses to the NVRAM storage attached to the Bluetooth
2187 ** controller.
2188 **
2189 ** Parameters: num_keys - Number of link keys
2190 ** bd_addr - Addresses of the devices
2191 ** link_key - Link Keys to be stored
2192 ** p_cb - Call back function to be called to return
2193 ** the results
2194 **
2195 *******************************************************************************/
BTM_WriteStoredLinkKey(UINT8 num_keys,BD_ADDR * bd_addr,LINK_KEY * link_key,tBTM_CMPL_CB * p_cb)2196 tBTM_STATUS BTM_WriteStoredLinkKey (UINT8 num_keys,
2197 BD_ADDR *bd_addr,
2198 LINK_KEY *link_key,
2199 tBTM_CMPL_CB *p_cb)
2200 {
2201 /* Check if the previous command is completed */
2202 if (btm_cb.devcb.p_stored_link_key_cmpl_cb)
2203 return (BTM_BUSY);
2204
2205 BTM_TRACE_EVENT1 ("BTM: BTM_WriteStoredLinkKey: num_keys: %d", num_keys);
2206
2207 /* Check the maximum number of link keys */
2208 if(num_keys > HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD)
2209 num_keys = HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD;
2210
2211 /* Send the HCI command */
2212 btm_cb.devcb.p_stored_link_key_cmpl_cb = p_cb;
2213 if (btsnd_hcic_write_stored_key (num_keys, bd_addr, link_key))
2214 return (BTM_SUCCESS);
2215 else
2216 return (BTM_NO_RESOURCES);
2217
2218 }
2219
2220
2221 /*******************************************************************************
2222 **
2223 ** Function BTM_DeleteStoredLinkKey
2224 **
2225 ** Description This function is called to delete link key for the specified
2226 ** device addresses from the NVRAM storage attached to the Bluetooth
2227 ** controller.
2228 **
2229 ** Parameters: bd_addr - Addresses of the devices
2230 ** p_cb - Call back function to be called to return
2231 ** the results
2232 **
2233 *******************************************************************************/
BTM_DeleteStoredLinkKey(BD_ADDR bd_addr,tBTM_CMPL_CB * p_cb)2234 tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb)
2235 {
2236 BD_ADDR local_bd_addr;
2237 BOOLEAN delete_all_flag = FALSE;
2238
2239 /* Check if the previous command is completed */
2240 if (btm_cb.devcb.p_stored_link_key_cmpl_cb)
2241 return (BTM_BUSY);
2242
2243 if (!bd_addr)
2244 {
2245 /* This is to delete all link keys */
2246 delete_all_flag = TRUE;
2247
2248 /* We don't care the BD address. Just pass a non zero pointer */
2249 bd_addr = local_bd_addr;
2250 }
2251
2252 BTM_TRACE_EVENT1 ("BTM: BTM_DeleteStoredLinkKey: delete_all_flag: %s",
2253 delete_all_flag ? "TRUE" : "FALSE");
2254
2255 /* Send the HCI command */
2256 btm_cb.devcb.p_stored_link_key_cmpl_cb = p_cb;
2257 if (!btsnd_hcic_delete_stored_key (bd_addr, delete_all_flag))
2258 {
2259 return (BTM_NO_RESOURCES);
2260 }
2261 else
2262 return (BTM_SUCCESS);
2263 }
2264
2265
2266 /*******************************************************************************
2267 **
2268 ** Function btm_read_stored_link_key_complete
2269 **
2270 ** Description This function is called when the command complete message
2271 ** is received from the HCI for the read stored link key command.
2272 **
2273 ** Returns void
2274 **
2275 *******************************************************************************/
btm_read_stored_link_key_complete(UINT8 * p)2276 void btm_read_stored_link_key_complete (UINT8 *p)
2277 {
2278 tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_stored_link_key_cmpl_cb;
2279 tBTM_READ_STORED_LINK_KEY_COMPLETE result;
2280
2281 /* If there was a callback registered for read stored link key, call it */
2282 btm_cb.devcb.p_stored_link_key_cmpl_cb = NULL;
2283
2284 if (p_cb)
2285 {
2286 /* Set the call back event to indicate command complete */
2287 result.event = BTM_CB_EVT_READ_STORED_LINK_KEYS;
2288
2289 /* Extract the result fields from the HCI event if status is success */
2290 STREAM_TO_UINT8 (result.status, p);
2291 if (result.status == HCI_SUCCESS)
2292 {
2293 STREAM_TO_UINT16 (result.max_keys, p);
2294 STREAM_TO_UINT16 (result.read_keys, p);
2295 }
2296 else
2297 {
2298 BTM_TRACE_WARNING1("Read stored link key status %d", result.status);
2299 result.max_keys = 0;
2300 result.read_keys = 0;
2301 }
2302 /* Call the call back and pass the result */
2303 (*p_cb)(&result);
2304 }
2305 }
2306
2307
2308 /*******************************************************************************
2309 **
2310 ** Function btm_write_stored_link_key_complete
2311 **
2312 ** Description This function is called when the command complete message
2313 ** is received from the HCI for the write stored link key command.
2314 **
2315 ** Returns void
2316 **
2317 *******************************************************************************/
btm_write_stored_link_key_complete(UINT8 * p)2318 void btm_write_stored_link_key_complete (UINT8 *p)
2319 {
2320 tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_stored_link_key_cmpl_cb;
2321 tBTM_WRITE_STORED_LINK_KEY_COMPLETE result;
2322
2323 /* If there was a callback registered for read stored link key, call it */
2324 btm_cb.devcb.p_stored_link_key_cmpl_cb = NULL;
2325
2326 if (p_cb)
2327 {
2328 /* Set the call back event to indicate command complete */
2329 result.event = BTM_CB_EVT_WRITE_STORED_LINK_KEYS;
2330
2331 /* Extract the result fields from the HCI event */
2332 STREAM_TO_UINT8 (result.status, p);
2333 STREAM_TO_UINT8 (result.num_keys, p);
2334
2335 /* Call the call back and pass the result */
2336 (*p_cb)(&result);
2337 }
2338 }
2339
2340
2341 /*******************************************************************************
2342 **
2343 ** Function btm_delete_stored_link_key_complete
2344 **
2345 ** Description This function is called when the command complete message
2346 ** is received from the HCI for the delete stored link key command.
2347 **
2348 ** Returns void
2349 **
2350 *******************************************************************************/
btm_delete_stored_link_key_complete(UINT8 * p)2351 void btm_delete_stored_link_key_complete (UINT8 *p)
2352 {
2353 tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_stored_link_key_cmpl_cb;
2354 tBTM_DELETE_STORED_LINK_KEY_COMPLETE result;
2355
2356 /* If there was a callback registered for read stored link key, call it */
2357 btm_cb.devcb.p_stored_link_key_cmpl_cb = NULL;
2358
2359 if (p_cb)
2360 {
2361 /* Set the call back event to indicate command complete */
2362 result.event = BTM_CB_EVT_DELETE_STORED_LINK_KEYS;
2363
2364 /* Extract the result fields from the HCI event */
2365 STREAM_TO_UINT8 (result.status, p);
2366 STREAM_TO_UINT16 (result.num_keys, p);
2367
2368 /* Call the call back and pass the result */
2369 (*p_cb)(&result);
2370 }
2371 }
2372
2373
2374 /*******************************************************************************
2375 **
2376 ** Function btm_return_link_keys_evt
2377 **
2378 ** Description This function is called when the return link keys event
2379 ** is received from the HCI for the read stored link key command.
2380 **
2381 ** Returns void
2382 **
2383 *******************************************************************************/
btm_return_link_keys_evt(tBTM_RETURN_LINK_KEYS_EVT * result)2384 void btm_return_link_keys_evt (tBTM_RETURN_LINK_KEYS_EVT *result)
2385 {
2386 tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_stored_link_key_cmpl_cb;
2387 UINT8 i, *p, *p1;
2388 UINT8 bd_addr[BD_ADDR_LEN];
2389 UINT8 link_key[LINK_KEY_LEN];
2390
2391 /* Call the call back to pass the link keys to application */
2392 if (p_cb)
2393 {
2394 /* Change the BD addr and Link key in to big endian order */
2395 p = (UINT8 *)(result + 1);
2396 for (i=0; i<result->num_keys; i++)
2397 {
2398 /* Initialize the backup pointer */
2399 p1 = p;
2400
2401 /* Extract the BD Addr and Link Key */
2402 REVERSE_STREAM_TO_ARRAY(bd_addr, p1, BD_ADDR_LEN);
2403 REVERSE_STREAM_TO_ARRAY(link_key, p1, LINK_KEY_LEN);
2404
2405 /* Write the BD Addr and Link Key back in big endian format */
2406 ARRAY_TO_STREAM(p, bd_addr, BD_ADDR_LEN);
2407 ARRAY_TO_STREAM(p, link_key, LINK_KEY_LEN);
2408 }
2409
2410 (*p_cb)(result);
2411 }
2412 }
2413
2414
2415
2416 /*******************************************************************************
2417 **
2418 ** Function btm_report_device_status
2419 **
2420 ** Description This function is called when there is a change in the device
2421 ** status. This function will report the new device status to
2422 ** the application
2423 **
2424 ** Returns void
2425 **
2426 *******************************************************************************/
btm_report_device_status(tBTM_DEV_STATUS status)2427 void btm_report_device_status (tBTM_DEV_STATUS status)
2428 {
2429 tBTM_DEV_STATUS_CB *p_cb = btm_cb.devcb.p_dev_status_cb;
2430
2431 /* Call the call back to pass the device status to application */
2432 if (p_cb)
2433 (*p_cb)(status);
2434 }
2435
2436
2437