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