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