1 /******************************************************************************
2 *
3 * Copyright (C) 2014 Google, Inc.
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 #include <stdbool.h>
19 #include "common/bt_target.h"
20 #include "common/bt_trace.h"
21 #include "device/bdaddr.h"
22 #include "stack/bt_types.h"
23 #include "device/controller.h"
24 #include "device/event_mask.h"
25 #include "stack/hcimsgs.h"
26 #include "hci/hci_layer.h"
27 #include "hci/hci_packet_factory.h"
28 #include "hci/hci_packet_parser.h"
29 #include "stack/btm_ble_api.h"
30 #include "device/version.h"
31 #include "osi/future.h"
32 #if (BLE_50_FEATURE_SUPPORT == TRUE)
33 const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x0f\xff\xff" };
34 #else
35 const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" };
36 #endif
37
38 #if (BLE_INCLUDED)
39 const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_DUMO_EVENT_MASK_EXT };
40 #else
41 const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_LISBON_EVENT_MASK_EXT };
42 #endif
43
44 // TODO(zachoverflow): factor out into common module
45 const uint8_t SCO_HOST_BUFFER_SIZE = 0xff;
46
47 #define HCI_SUPPORTED_COMMANDS_ARRAY_SIZE 64
48 #define MAX_FEATURES_CLASSIC_PAGE_COUNT 3
49 #define BLE_SUPPORTED_STATES_SIZE 8
50 #define BLE_SUPPORTED_FEATURES_SIZE 8
51 #define BLE_EXT_ADV_DATA_LEN_MAX 1650
52
53 typedef struct {
54 const hci_t *hci;
55 const hci_packet_factory_t *packet_factory;
56 const hci_packet_parser_t *packet_parser;
57
58 bt_version_t bt_version;
59 bt_bdaddr_t address;
60
61 uint8_t supported_commands[HCI_SUPPORTED_COMMANDS_ARRAY_SIZE];
62 uint8_t last_features_classic_page_index;
63 bt_device_features_t features_classic[MAX_FEATURES_CLASSIC_PAGE_COUNT];
64
65 uint16_t acl_data_size_classic;
66 uint16_t acl_data_size_ble;
67 uint16_t acl_buffer_count_classic;
68 uint8_t acl_buffer_count_ble;
69
70 uint8_t sco_data_size;
71 uint16_t sco_buffer_count;
72
73 uint8_t ble_white_list_size;
74 uint8_t ble_resolving_list_max_size;
75 uint8_t ble_supported_states[BLE_SUPPORTED_STATES_SIZE];
76 bt_device_features_t features_ble;
77 uint16_t ble_suggested_default_data_length;
78 uint16_t ble_suggested_default_data_txtime;
79
80 bool readable;
81 bool ble_supported;
82 bool simple_pairing_supported;
83 bool secure_connections_supported;
84 #if (BLE_50_FEATURE_SUPPORT == TRUE)
85 uint16_t ble_ext_adv_data_max_len;
86 #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
87 } controller_local_param_t;
88
89 #if BT_BLE_DYNAMIC_ENV_MEMORY == FALSE
90 static controller_local_param_t controller_param;
91 #else
92 static controller_local_param_t *controller_param_ptr;
93 #define controller_param (*controller_param_ptr)
94 #endif
95
96 #define AWAIT_COMMAND(command) future_await(controller_param.hci->transmit_command_futured(command))
97
98 // Module lifecycle functions
99
start_up(void)100 static void start_up(void)
101 {
102 BT_HDR *response;
103
104 // Send the initial reset command
105 response = AWAIT_COMMAND(controller_param.packet_factory->make_reset());
106 controller_param.packet_parser->parse_generic_command_complete(response);
107
108 #if (CLASSIC_BT_INCLUDED)
109 // Request the classic buffer size next
110 response = AWAIT_COMMAND(controller_param.packet_factory->make_read_buffer_size());
111 controller_param.packet_parser->parse_read_buffer_size_response(
112 response, &controller_param.acl_data_size_classic, &controller_param.acl_buffer_count_classic,
113 &controller_param.sco_data_size, &controller_param.sco_buffer_count);
114 #endif
115
116 #if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
117 // Enable controller to host flow control
118 response = AWAIT_COMMAND(controller_param.packet_factory->make_set_c2h_flow_control(HCI_HOST_FLOW_CTRL_ACL_ON));
119 controller_param.packet_parser->parse_generic_command_complete(response);
120 #endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
121 #if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
122 // Enable adv flow control
123 response = AWAIT_COMMAND(controller_param.packet_factory->make_set_adv_report_flow_control(HCI_HOST_FLOW_CTRL_ADV_REPORT_ON, (uint16_t)BLE_ADV_REPORT_FLOW_CONTROL_NUM, (uint16_t)BLE_ADV_REPORT_DISCARD_THRSHOLD));
124 controller_param.packet_parser->parse_generic_command_complete(response);
125 #endif
126 // Tell the controller about our buffer sizes and buffer counts next
127 // TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10?
128 response = AWAIT_COMMAND(
129 controller_param.packet_factory->make_host_buffer_size(
130 L2CAP_MTU_SIZE,
131 SCO_HOST_BUFFER_SIZE,
132 L2CAP_HOST_FC_ACL_BUFS,
133 10
134 )
135 );
136
137 controller_param.packet_parser->parse_generic_command_complete(response);
138
139 // Read the local version info off the controller next, including
140 // information such as manufacturer and supported HCI version
141 response = AWAIT_COMMAND(controller_param.packet_factory->make_read_local_version_info());
142 controller_param.packet_parser->parse_read_local_version_info_response(response, &controller_param.bt_version);
143
144 // Read the bluetooth address off the controller next
145 response = AWAIT_COMMAND(controller_param.packet_factory->make_read_bd_addr());
146 controller_param.packet_parser->parse_read_bd_addr_response(response, &controller_param.address);
147
148 // Request the controller's supported commands next
149 response = AWAIT_COMMAND(controller_param.packet_factory->make_read_local_supported_commands());
150 controller_param.packet_parser->parse_read_local_supported_commands_response(
151 response,
152 controller_param.supported_commands,
153 HCI_SUPPORTED_COMMANDS_ARRAY_SIZE
154 );
155
156 #if (CLASSIC_BT_INCLUDED)
157 // Read page 0 of the controller features next
158 uint8_t page_number = 0;
159 response = AWAIT_COMMAND(controller_param.packet_factory->make_read_local_extended_features(page_number));
160 controller_param.packet_parser->parse_read_local_extended_features_response(
161 response,
162 &page_number,
163 &controller_param.last_features_classic_page_index,
164 controller_param.features_classic,
165 MAX_FEATURES_CLASSIC_PAGE_COUNT
166 );
167
168 assert(page_number == 0);
169 page_number++;
170 #endif
171
172 // Inform the controller what page 0 features we support, based on what
173 // it told us it supports. We need to do this first before we request the
174 // next page, because the controller's response for page 1 may be
175 // dependent on what we configure from page 0
176 #if (BT_SSP_INCLUDED == TRUE)
177 controller_param.simple_pairing_supported = HCI_SIMPLE_PAIRING_SUPPORTED(controller_param.features_classic[0].as_array);
178 #else
179 controller_param.simple_pairing_supported = false;
180 #endif
181
182 if (controller_param.simple_pairing_supported) {
183 response = AWAIT_COMMAND(controller_param.packet_factory->make_write_simple_pairing_mode(HCI_SP_MODE_ENABLED));
184 controller_param.packet_parser->parse_generic_command_complete(response);
185 }
186
187 #if (BLE_INCLUDED == TRUE)
188 if (HCI_LE_SPT_SUPPORTED(controller_param.features_classic[0].as_array)) {
189 uint8_t simultaneous_le_host = HCI_SIMUL_LE_BREDR_SUPPORTED(controller_param.features_classic[0].as_array) ? BTM_BLE_SIMULTANEOUS_HOST : 0;
190 response = AWAIT_COMMAND(
191 controller_param.packet_factory->make_ble_write_host_support(BTM_BLE_HOST_SUPPORT, simultaneous_le_host)
192 );
193
194 controller_param.packet_parser->parse_generic_command_complete(response);
195 }
196 #endif
197
198 #if (CLASSIC_BT_INCLUDED)
199 // Done telling the controller about what page 0 features we support
200 // Request the remaining feature pages
201 while (page_number <= controller_param.last_features_classic_page_index &&
202 page_number < MAX_FEATURES_CLASSIC_PAGE_COUNT) {
203 response = AWAIT_COMMAND(controller_param.packet_factory->make_read_local_extended_features(page_number));
204 controller_param.packet_parser->parse_read_local_extended_features_response(
205 response,
206 &page_number,
207 &controller_param.last_features_classic_page_index,
208 controller_param.features_classic,
209 MAX_FEATURES_CLASSIC_PAGE_COUNT
210 );
211
212 page_number++;
213 }
214 #endif
215
216 #if (SC_MODE_INCLUDED == TRUE)
217 controller_param.secure_connections_supported = HCI_SC_CTRLR_SUPPORTED(controller_param.features_classic[2].as_array);
218 if (controller_param.secure_connections_supported) {
219 response = AWAIT_COMMAND(controller_param.packet_factory->make_write_secure_connections_host_support(HCI_SC_MODE_ENABLED));
220 controller_param.packet_parser->parse_generic_command_complete(response);
221 }
222 #endif
223
224 #if (BLE_INCLUDED == TRUE)
225 #if (CLASSIC_BT_INCLUDED)
226 controller_param.ble_supported = controller_param.last_features_classic_page_index >= 1 && HCI_LE_HOST_SUPPORTED(controller_param.features_classic[1].as_array);
227 #else
228 controller_param.ble_supported = true;
229 #endif
230 if (controller_param.ble_supported) {
231 // Request the ble white list size next
232 response = AWAIT_COMMAND(controller_param.packet_factory->make_ble_read_white_list_size());
233 controller_param.packet_parser->parse_ble_read_white_list_size_response(response, &controller_param.ble_white_list_size);
234
235 // Request the ble buffer size next
236 response = AWAIT_COMMAND(controller_param.packet_factory->make_ble_read_buffer_size());
237 controller_param.packet_parser->parse_ble_read_buffer_size_response(
238 response,
239 &controller_param.acl_data_size_ble,
240 &controller_param.acl_buffer_count_ble
241 );
242
243 // Response of 0 indicates ble has the same buffer size as classic
244 if (controller_param.acl_data_size_ble == 0) {
245 controller_param.acl_data_size_ble = controller_param.acl_data_size_classic;
246 }
247
248 // Request the ble supported states next
249 response = AWAIT_COMMAND(controller_param.packet_factory->make_ble_read_supported_states());
250 controller_param.packet_parser->parse_ble_read_supported_states_response(
251 response,
252 controller_param.ble_supported_states,
253 sizeof(controller_param.ble_supported_states)
254 );
255
256 // Request the ble supported features next
257 response = AWAIT_COMMAND(controller_param.packet_factory->make_ble_read_local_supported_features());
258 controller_param.packet_parser->parse_ble_read_local_supported_features_response(
259 response,
260 &controller_param.features_ble
261 );
262
263 if (HCI_LE_ENHANCED_PRIVACY_SUPPORTED(controller_param.features_ble.as_array)) {
264 response = AWAIT_COMMAND(controller_param.packet_factory->make_ble_read_resolving_list_size());
265 controller_param.packet_parser->parse_ble_read_resolving_list_size_response(
266 response,
267 &controller_param.ble_resolving_list_max_size);
268 }
269 #if BLE_50_FEATURE_SUPPORT == TRUE
270 controller_param.ble_ext_adv_data_max_len = BLE_EXT_ADV_DATA_LEN_MAX;
271 #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
272
273 #if (BLE_50_FEATURE_SUPPORT == TRUE && BLE_42_FEATURE_SUPPORT == FALSE)
274 if (HCI_LE_ENHANCED_PRIVACY_SUPPORTED(controller_param.features_ble.as_array)) {
275 response = AWAIT_COMMAND(controller_param.packet_factory->make_read_max_adv_data_len());
276 controller_param.packet_parser->parse_ble_read_adv_max_len_response(
277 response,
278 &controller_param.ble_ext_adv_data_max_len);
279 }
280 #endif // (BLE_50_FEATURE_SUPPORT == TRUE && BLE_42_FEATURE_SUPPORT == FALSE)
281
282 if (HCI_LE_DATA_LEN_EXT_SUPPORTED(controller_param.features_ble.as_array)) {
283 /* set default tx data length to MAX 251 */
284 response = AWAIT_COMMAND(controller_param.packet_factory->make_ble_write_suggested_default_data_length(BTM_BLE_DATA_SIZE_MAX, BTM_BLE_DATA_TX_TIME_MAX));
285 controller_param.packet_parser->parse_generic_command_complete(response);
286
287 response = AWAIT_COMMAND(controller_param.packet_factory->make_ble_read_suggested_default_data_length());
288 controller_param.packet_parser->parse_ble_read_suggested_default_data_length_response(
289 response,
290 &controller_param.ble_suggested_default_data_length,
291 &controller_param.ble_suggested_default_data_txtime);
292 }
293
294 // Set the ble event mask next
295 response = AWAIT_COMMAND(controller_param.packet_factory->make_ble_set_event_mask(&BLE_EVENT_MASK));
296 controller_param.packet_parser->parse_generic_command_complete(response);
297 }
298 #endif
299
300 response = AWAIT_COMMAND(controller_param.packet_factory->make_set_event_mask(&CLASSIC_EVENT_MASK));
301 controller_param.packet_parser->parse_generic_command_complete(response);
302
303 #if (BTM_SCO_HCI_INCLUDED == TRUE)
304 response = AWAIT_COMMAND(controller_param.packet_factory->make_write_sync_flow_control_enable(1));
305 controller_param.packet_parser->parse_generic_command_complete(response);
306
307 response = AWAIT_COMMAND(controller_param.packet_factory->make_write_default_erroneous_data_report(1));
308 controller_param.packet_parser->parse_generic_command_complete(response);
309 #endif
310 controller_param.readable = true;
311 // return future_new_immediate(FUTURE_SUCCESS);
312 return;
313 }
314
shut_down(void)315 static void shut_down(void)
316 {
317 controller_param.readable = false;
318 }
319
get_is_ready(void)320 static bool get_is_ready(void)
321 {
322 return controller_param.readable;
323 }
324
get_address(void)325 static const bt_bdaddr_t *get_address(void)
326 {
327 assert(controller_param.readable);
328 return &controller_param.address;
329 }
330
get_bt_version(void)331 static const bt_version_t *get_bt_version(void)
332 {
333 assert(controller_param.readable);
334 return &controller_param.bt_version;
335 }
336
337 // TODO(zachoverflow): hide inside, move decoder inside too
get_features_classic(int index)338 static const bt_device_features_t *get_features_classic(int index)
339 {
340 assert(controller_param.readable);
341 assert(index < MAX_FEATURES_CLASSIC_PAGE_COUNT);
342 return &controller_param.features_classic[index];
343 }
344
get_last_features_classic_index(void)345 static uint8_t get_last_features_classic_index(void)
346 {
347 assert(controller_param.readable);
348 return controller_param.last_features_classic_page_index;
349 }
350
get_features_ble(void)351 static const bt_device_features_t *get_features_ble(void)
352 {
353 assert(controller_param.readable);
354 assert(controller_param.ble_supported);
355 return &controller_param.features_ble;
356 }
357
get_ble_supported_states(void)358 static const uint8_t *get_ble_supported_states(void)
359 {
360 assert(controller_param.readable);
361 assert(controller_param.ble_supported);
362 return controller_param.ble_supported_states;
363 }
364
supports_simple_pairing(void)365 static bool supports_simple_pairing(void)
366 {
367 assert(controller_param.readable);
368 return controller_param.simple_pairing_supported;
369 }
370
supports_secure_connections(void)371 static bool supports_secure_connections(void)
372 {
373 assert(controller_param.readable);
374 return controller_param.secure_connections_supported;
375 }
376
supports_simultaneous_le_bredr(void)377 static bool supports_simultaneous_le_bredr(void)
378 {
379 assert(controller_param.readable);
380 return HCI_SIMUL_LE_BREDR_SUPPORTED(controller_param.features_classic[0].as_array);
381 }
382
supports_reading_remote_extended_features(void)383 static bool supports_reading_remote_extended_features(void)
384 {
385 assert(controller_param.readable);
386 return HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(controller_param.supported_commands);
387 }
388
supports_interlaced_inquiry_scan(void)389 static bool supports_interlaced_inquiry_scan(void)
390 {
391 assert(controller_param.readable);
392 return HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(controller_param.features_classic[0].as_array);
393 }
394
supports_rssi_with_inquiry_results(void)395 static bool supports_rssi_with_inquiry_results(void)
396 {
397 assert(controller_param.readable);
398 return HCI_LMP_INQ_RSSI_SUPPORTED(controller_param.features_classic[0].as_array);
399 }
400
supports_extended_inquiry_response(void)401 static bool supports_extended_inquiry_response(void)
402 {
403 assert(controller_param.readable);
404 return HCI_EXT_INQ_RSP_SUPPORTED(controller_param.features_classic[0].as_array);
405 }
406
supports_master_slave_role_switch(void)407 static bool supports_master_slave_role_switch(void)
408 {
409 assert(controller_param.readable);
410 return HCI_SWITCH_SUPPORTED(controller_param.features_classic[0].as_array);
411 }
412
supports_ble(void)413 static bool supports_ble(void)
414 {
415 assert(controller_param.readable);
416 return controller_param.ble_supported;
417 }
418
supports_ble_privacy(void)419 static bool supports_ble_privacy(void)
420 {
421 assert(controller_param.readable);
422 assert(controller_param.ble_supported);
423 return HCI_LE_ENHANCED_PRIVACY_SUPPORTED(controller_param.features_ble.as_array);
424 }
425
supports_ble_packet_extension(void)426 static bool supports_ble_packet_extension(void)
427 {
428 assert(controller_param.readable);
429 assert(controller_param.ble_supported);
430 return HCI_LE_DATA_LEN_EXT_SUPPORTED(controller_param.features_ble.as_array);
431 }
432
supports_ble_connection_parameters_request(void)433 static bool supports_ble_connection_parameters_request(void)
434 {
435 assert(controller_param.readable);
436 assert(controller_param.ble_supported);
437 return HCI_LE_CONN_PARAM_REQ_SUPPORTED(controller_param.features_ble.as_array);
438 }
439
get_acl_data_size_classic(void)440 static uint16_t get_acl_data_size_classic(void)
441 {
442 assert(controller_param.readable);
443 return controller_param.acl_data_size_classic;
444 }
445
get_acl_data_size_ble(void)446 static uint16_t get_acl_data_size_ble(void)
447 {
448 assert(controller_param.readable);
449 assert(controller_param.ble_supported);
450 return controller_param.acl_data_size_ble;
451 }
452
get_acl_packet_size_classic(void)453 static uint16_t get_acl_packet_size_classic(void)
454 {
455 assert(controller_param.readable);
456 return controller_param.acl_data_size_classic + HCI_DATA_PREAMBLE_SIZE;
457 }
458
get_acl_packet_size_ble(void)459 static uint16_t get_acl_packet_size_ble(void)
460 {
461 assert(controller_param.readable);
462 return controller_param.acl_data_size_ble + HCI_DATA_PREAMBLE_SIZE;
463 }
464
get_ble_suggested_default_data_length(void)465 static uint16_t get_ble_suggested_default_data_length(void)
466 {
467 assert(controller_param.readable);
468 assert(controller_param.ble_supported);
469 return controller_param.ble_suggested_default_data_length;
470 }
471
get_ble_suggested_default_data_txtime(void)472 static uint16_t get_ble_suggested_default_data_txtime(void)
473 {
474 assert(controller_param.readable);
475 assert(controller_param.ble_supported);
476 return controller_param.ble_suggested_default_data_txtime;
477 }
478
get_acl_buffer_count_classic(void)479 static uint16_t get_acl_buffer_count_classic(void)
480 {
481 assert(controller_param.readable);
482 return controller_param.acl_buffer_count_classic;
483 }
484
get_acl_buffer_count_ble(void)485 static uint8_t get_acl_buffer_count_ble(void)
486 {
487 assert(controller_param.readable);
488 assert(controller_param.ble_supported);
489 return controller_param.acl_buffer_count_ble;
490 }
491
get_ble_white_list_size(void)492 static uint8_t get_ble_white_list_size(void)
493 {
494 assert(controller_param.readable);
495 assert(controller_param.ble_supported);
496 return controller_param.ble_white_list_size;
497 }
498
get_ble_resolving_list_max_size(void)499 static uint8_t get_ble_resolving_list_max_size(void)
500 {
501 assert(controller_param.readable);
502 assert(controller_param.ble_supported);
503 return controller_param.ble_resolving_list_max_size;
504 }
505
set_ble_resolving_list_max_size(int resolving_list_max_size)506 static void set_ble_resolving_list_max_size(int resolving_list_max_size)
507 {
508 assert(controller_param.readable);
509 assert(controller_param.ble_supported);
510 controller_param.ble_resolving_list_max_size = resolving_list_max_size;
511 }
512 #if (BLE_50_FEATURE_SUPPORT == TRUE)
ble_get_ext_adv_data_max_len(void)513 static uint16_t ble_get_ext_adv_data_max_len(void)
514 {
515 assert(controller_param.readable);
516 assert(controller_param.ble_supported);
517
518 return controller_param.ble_ext_adv_data_max_len;
519 }
520 #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
521 #if (BTM_SCO_HCI_INCLUDED == TRUE)
get_sco_data_size(void)522 static uint8_t get_sco_data_size(void)
523 {
524 assert(controller_param.readable);
525 return controller_param.sco_data_size;
526 }
527
get_sco_buffer_count(void)528 static uint8_t get_sco_buffer_count(void)
529 {
530 assert(controller_param.readable);
531 return controller_param.sco_buffer_count;
532 }
533 #endif /* (BTM_SCO_HCI_INCLUDED == TRUE) */
534
535 static const controller_t interface = {
536 start_up,
537 shut_down,
538 get_is_ready,
539
540 get_address,
541 get_bt_version,
542
543 get_features_classic,
544 get_last_features_classic_index,
545
546 get_features_ble,
547 get_ble_supported_states,
548
549 supports_simple_pairing,
550 supports_secure_connections,
551 supports_simultaneous_le_bredr,
552 supports_reading_remote_extended_features,
553 supports_interlaced_inquiry_scan,
554 supports_rssi_with_inquiry_results,
555 supports_extended_inquiry_response,
556 supports_master_slave_role_switch,
557
558 supports_ble,
559 supports_ble_packet_extension,
560 supports_ble_connection_parameters_request,
561 supports_ble_privacy,
562
563 get_acl_data_size_classic,
564 get_acl_data_size_ble,
565
566 get_acl_packet_size_classic,
567 get_acl_packet_size_ble,
568 get_ble_suggested_default_data_length,
569 get_ble_suggested_default_data_txtime,
570
571 get_acl_buffer_count_classic,
572 get_acl_buffer_count_ble,
573
574 get_ble_white_list_size,
575
576 get_ble_resolving_list_max_size,
577 set_ble_resolving_list_max_size,
578 #if (BLE_50_FEATURE_SUPPORT == TRUE)
579 ble_get_ext_adv_data_max_len,
580 #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
581 #if (BTM_SCO_HCI_INCLUDED == TRUE)
582 get_sco_data_size,
583 get_sco_buffer_count,
584 #endif /* (BTM_SCO_HCI_INCLUDED == TRUE) */
585 };
586
controller_get_interface(void)587 const controller_t *controller_get_interface(void)
588 {
589 static bool loaded = false;
590 if (!loaded) {
591 loaded = true;
592 #if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
593 controller_param_ptr = (controller_local_param_t *)osi_calloc(sizeof(controller_local_param_t));
594 assert(controller_param_ptr);
595 #endif
596 controller_param.hci = hci_layer_get_interface();
597 controller_param.packet_factory = hci_packet_factory_get_interface();
598 controller_param.packet_parser = hci_packet_parser_get_interface();
599 }
600
601 return &interface;
602 }
603