Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Jakub Pawlowski | 5b790fe | 2017-09-18 09:00:20 -0700 | [diff] [blame] | 3 | * Copyright 2014 Google, Inc. |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 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" |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 32 | |
Jakub Pawlowski | 692a0ca | 2018-04-19 02:32:40 -0700 | [diff] [blame] | 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}}; |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 42 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 43 | 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] | 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 |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 50 | #define BLE_SUPPORTED_STATES_SIZE 8 |
| 51 | #define BLE_SUPPORTED_FEATURES_SIZE 8 |
| 52 | #define MAX_LOCAL_SUPPORTED_CODECS_SIZE 8 |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 53 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 54 | static const hci_t* hci; |
| 55 | static const hci_packet_factory_t* packet_factory; |
| 56 | static const hci_packet_parser_t* packet_parser; |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 57 | |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 58 | static RawAddress address; |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 59 | static bt_version_t bt_version; |
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 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; |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 64 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 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; |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 71 | static uint8_t ble_resolving_list_max_size; |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 72 | static uint8_t ble_supported_states[BLE_SUPPORTED_STATES_SIZE]; |
| 73 | static bt_device_features_t features_ble; |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 74 | static uint16_t ble_suggested_default_data_length; |
Jakub Pawlowski | 4f0c5b5 | 2018-02-02 22:05:11 -0800 | [diff] [blame] | 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 | |
Jakub Pawlowski | 1f4cc6d | 2016-11-28 11:16:04 -0800 | [diff] [blame] | 80 | static uint16_t ble_maxium_advertising_data_length; |
| 81 | static uint8_t ble_number_of_supported_advertising_sets; |
Srinu Jella | f6dcf79 | 2015-07-22 17:30:32 +0530 | [diff] [blame] | 82 | static uint8_t local_supported_codecs[MAX_LOCAL_SUPPORTED_CODECS_SIZE]; |
| 83 | static uint8_t number_of_local_supported_codecs = 0; |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 84 | |
| 85 | static bool readable; |
| 86 | static bool ble_supported; |
| 87 | static bool simple_pairing_supported; |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 88 | static bool secure_connections_supported; |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 89 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 90 | #define AWAIT_COMMAND(command) \ |
| 91 | static_cast<BT_HDR*>(future_await(hci->transmit_command_futured(command))) |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 92 | |
| 93 | // Module lifecycle functions |
| 94 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 95 | static future_t* start_up(void) { |
| 96 | BT_HDR* response; |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 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 |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 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)); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 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 |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 125 | response = |
| 126 | AWAIT_COMMAND(packet_factory->make_read_local_supported_commands()); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 127 | packet_parser->parse_read_local_supported_commands_response( |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 128 | response, supported_commands, HCI_SUPPORTED_COMMANDS_ARRAY_SIZE); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 129 | |
| 130 | // Read page 0 of the controller features next |
| 131 | uint8_t page_number = 0; |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 132 | response = AWAIT_COMMAND( |
| 133 | packet_factory->make_read_local_extended_features(page_number)); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 134 | packet_parser->parse_read_local_extended_features_response( |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 135 | response, &page_number, &last_features_classic_page_index, |
| 136 | features_classic, MAX_FEATURES_CLASSIC_PAGE_COUNT); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 137 | |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 138 | CHECK(page_number == 0); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 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 |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 145 | simple_pairing_supported = |
| 146 | HCI_SIMPLE_PAIRING_SUPPORTED(features_classic[0].as_array); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 147 | if (simple_pairing_supported) { |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 148 | response = AWAIT_COMMAND( |
| 149 | packet_factory->make_write_simple_pairing_mode(HCI_SP_MODE_ENABLED)); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 150 | packet_parser->parse_generic_command_complete(response); |
| 151 | } |
| 152 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 153 | if (HCI_LE_SPT_SUPPORTED(features_classic[0].as_array)) { |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 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)); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 160 | |
| 161 | packet_parser->parse_generic_command_complete(response); |
Frédéric Dalleau | ebc367a | 2015-08-18 12:23:12 +0200 | [diff] [blame] | 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; |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 166 | } |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 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) { |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 172 | response = AWAIT_COMMAND( |
| 173 | packet_factory->make_read_local_extended_features(page_number)); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 174 | packet_parser->parse_read_local_extended_features_response( |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 175 | response, &page_number, &last_features_classic_page_index, |
| 176 | features_classic, MAX_FEATURES_CLASSIC_PAGE_COUNT); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 177 | |
| 178 | page_number++; |
| 179 | } |
| 180 | |
Andre Eisenbach | 67a784b | 2015-05-26 17:40:12 -0700 | [diff] [blame] | 181 | #if (SC_MODE_INCLUDED == TRUE) |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 182 | secure_connections_supported = |
| 183 | HCI_SC_CTRLR_SUPPORTED(features_classic[2].as_array); |
Mudumba Ananth | 899b771 | 2015-01-30 02:33:02 -0800 | [diff] [blame] | 184 | if (secure_connections_supported) { |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 185 | response = AWAIT_COMMAND( |
| 186 | packet_factory->make_write_secure_connections_host_support( |
| 187 | HCI_SC_MODE_ENABLED)); |
Mudumba Ananth | 899b771 | 2015-01-30 02:33:02 -0800 | [diff] [blame] | 188 | packet_parser->parse_generic_command_complete(response); |
| 189 | } |
Andre Eisenbach | 67a784b | 2015-05-26 17:40:12 -0700 | [diff] [blame] | 190 | #endif |
Mudumba Ananth | 899b771 | 2015-01-30 02:33:02 -0800 | [diff] [blame] | 191 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 192 | ble_supported = last_features_classic_page_index >= 1 && |
| 193 | HCI_LE_HOST_SUPPORTED(features_classic[1].as_array); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 194 | if (ble_supported) { |
| 195 | // Request the ble white list size next |
| 196 | response = AWAIT_COMMAND(packet_factory->make_ble_read_white_list_size()); |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 197 | packet_parser->parse_ble_read_white_list_size_response( |
| 198 | response, &ble_white_list_size); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 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( |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 203 | response, &acl_data_size_ble, &acl_buffer_count_ble); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 204 | |
| 205 | // Response of 0 indicates ble has the same buffer size as classic |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 206 | 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] | 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( |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 211 | response, ble_supported_states, sizeof(ble_supported_states)); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 212 | |
| 213 | // Request the ble supported features next |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 214 | response = |
| 215 | AWAIT_COMMAND(packet_factory->make_ble_read_local_supported_features()); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 216 | packet_parser->parse_ble_read_local_supported_features_response( |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 217 | response, &features_ble); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 218 | |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 219 | if (HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array)) { |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 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); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 224 | } |
| 225 | |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 226 | if (HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array)) { |
Jakub Pawlowski | 4f0c5b5 | 2018-02-02 22:05:11 -0800 | [diff] [blame] | 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 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 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); |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 237 | } |
| 238 | |
Jakub Pawlowski | 1f4cc6d | 2016-11-28 11:16:04 -0800 | [diff] [blame] | 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); |
Jakub Pawlowski | 5a8a162 | 2017-03-16 18:19:20 -0700 | [diff] [blame] | 249 | } else { |
| 250 | /* If LE Excended Advertising is not supported, use the default value */ |
| 251 | ble_maxium_advertising_data_length = 31; |
Jakub Pawlowski | 1f4cc6d | 2016-11-28 11:16:04 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 254 | // Set the ble event mask next |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 255 | response = |
| 256 | AWAIT_COMMAND(packet_factory->make_ble_set_event_mask(&BLE_EVENT_MASK)); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 257 | packet_parser->parse_generic_command_complete(response); |
| 258 | } |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 259 | |
| 260 | if (simple_pairing_supported) { |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 261 | response = |
| 262 | AWAIT_COMMAND(packet_factory->make_set_event_mask(&CLASSIC_EVENT_MASK)); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 263 | packet_parser->parse_generic_command_complete(response); |
| 264 | } |
| 265 | |
Srinu Jella | f6dcf79 | 2015-07-22 17:30:32 +0530 | [diff] [blame] | 266 | // read local supported codecs |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 267 | if (HCI_READ_LOCAL_CODECS_SUPPORTED(supported_commands)) { |
| 268 | response = |
| 269 | AWAIT_COMMAND(packet_factory->make_read_local_supported_codecs()); |
Srinu Jella | f6dcf79 | 2015-07-22 17:30:32 +0530 | [diff] [blame] | 270 | packet_parser->parse_read_local_supported_codecs_response( |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 271 | response, &number_of_local_supported_codecs, local_supported_codecs); |
Srinu Jella | f6dcf79 | 2015-07-22 17:30:32 +0530 | [diff] [blame] | 272 | } |
| 273 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 274 | readable = true; |
| 275 | return future_new_immediate(FUTURE_SUCCESS); |
| 276 | } |
| 277 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 278 | static future_t* shut_down(void) { |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 279 | readable = false; |
| 280 | return future_new_immediate(FUTURE_SUCCESS); |
| 281 | } |
| 282 | |
Pavlin Radoslavov | b2a292b | 2016-10-14 19:34:48 -0700 | [diff] [blame] | 283 | EXPORT_SYMBOL extern const module_t controller_module = { |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 284 | .name = CONTROLLER_MODULE, |
| 285 | .init = NULL, |
| 286 | .start_up = start_up, |
| 287 | .shut_down = shut_down, |
| 288 | .clean_up = NULL, |
| 289 | .dependencies = {HCI_MODULE, NULL}}; |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 290 | |
| 291 | // Interface functions |
| 292 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 293 | static bool get_is_ready(void) { return readable; } |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 294 | |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 295 | static const RawAddress* get_address(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 296 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 297 | return &address; |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 300 | static const bt_version_t* get_bt_version(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 301 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 302 | return &bt_version; |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 303 | } |
| 304 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 305 | // TODO(zachoverflow): hide inside, move decoder inside too |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 306 | static const bt_device_features_t* get_features_classic(int index) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 307 | CHECK(readable); |
| 308 | CHECK(index < MAX_FEATURES_CLASSIC_PAGE_COUNT); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 309 | return &features_classic[index]; |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 310 | } |
| 311 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 312 | static uint8_t get_last_features_classic_index(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 313 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 314 | return last_features_classic_page_index; |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 315 | } |
| 316 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 317 | static uint8_t* get_local_supported_codecs(uint8_t* number_of_codecs) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 318 | CHECK(readable); |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 319 | if (number_of_local_supported_codecs) { |
Srinu Jella | f6dcf79 | 2015-07-22 17:30:32 +0530 | [diff] [blame] | 320 | *number_of_codecs = number_of_local_supported_codecs; |
| 321 | return local_supported_codecs; |
| 322 | } |
| 323 | return NULL; |
| 324 | } |
| 325 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 326 | static const bt_device_features_t* get_features_ble(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 327 | CHECK(readable); |
| 328 | CHECK(ble_supported); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 329 | return &features_ble; |
| 330 | } |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 331 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 332 | static const uint8_t* get_ble_supported_states(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 333 | CHECK(readable); |
| 334 | CHECK(ble_supported); |
Zach Johnson | a87c821 | 2014-10-28 17:59:13 -0700 | [diff] [blame] | 335 | return ble_supported_states; |
| 336 | } |
| 337 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 338 | static bool supports_simple_pairing(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 339 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 340 | return simple_pairing_supported; |
| 341 | } |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 342 | |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 343 | static bool supports_secure_connections(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 344 | CHECK(readable); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 345 | return secure_connections_supported; |
| 346 | } |
| 347 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 348 | static bool supports_simultaneous_le_bredr(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 349 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 350 | return HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array); |
| 351 | } |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 352 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 353 | static bool supports_reading_remote_extended_features(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 354 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 355 | return HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(supported_commands); |
| 356 | } |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 357 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 358 | static bool supports_interlaced_inquiry_scan(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 359 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 360 | return HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(features_classic[0].as_array); |
| 361 | } |
| 362 | |
| 363 | static bool supports_rssi_with_inquiry_results(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 364 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 365 | return HCI_LMP_INQ_RSSI_SUPPORTED(features_classic[0].as_array); |
| 366 | } |
| 367 | |
| 368 | static bool supports_extended_inquiry_response(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 369 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 370 | return HCI_EXT_INQ_RSP_SUPPORTED(features_classic[0].as_array); |
| 371 | } |
| 372 | |
| 373 | static bool supports_master_slave_role_switch(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 374 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 375 | return HCI_SWITCH_SUPPORTED(features_classic[0].as_array); |
| 376 | } |
| 377 | |
Mudumba Ananth | 57f6508 | 2017-02-09 09:05:48 -0800 | [diff] [blame] | 378 | static bool supports_enhanced_setup_synchronous_connection(void) { |
| 379 | assert(readable); |
| 380 | return HCI_ENH_SETUP_SYNCH_CONN_SUPPORTED(supported_commands); |
| 381 | } |
| 382 | |
| 383 | static bool supports_enhanced_accept_synchronous_connection(void) { |
| 384 | assert(readable); |
| 385 | return HCI_ENH_ACCEPT_SYNCH_CONN_SUPPORTED(supported_commands); |
| 386 | } |
| 387 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 388 | static bool supports_ble(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 389 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 390 | return ble_supported; |
| 391 | } |
| 392 | |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 393 | static bool supports_ble_privacy(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 394 | CHECK(readable); |
| 395 | CHECK(ble_supported); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 396 | return HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array); |
| 397 | } |
| 398 | |
Jakub Pawlowski | ba78601 | 2017-06-26 11:26:46 -0700 | [diff] [blame] | 399 | static bool supports_ble_set_privacy_mode() { |
| 400 | CHECK(readable); |
| 401 | CHECK(ble_supported); |
| 402 | return HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array) && |
| 403 | HCI_LE_SET_PRIVACY_MODE_SUPPORTED(supported_commands); |
| 404 | } |
| 405 | |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 406 | static bool supports_ble_packet_extension(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 407 | CHECK(readable); |
| 408 | CHECK(ble_supported); |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 409 | return HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array); |
| 410 | } |
| 411 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 412 | static bool supports_ble_connection_parameters_request(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 413 | CHECK(readable); |
| 414 | CHECK(ble_supported); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 415 | return HCI_LE_CONN_PARAM_REQ_SUPPORTED(features_ble.as_array); |
| 416 | } |
| 417 | |
Jakub Pawlowski | 4b1feb6 | 2017-03-09 18:11:43 -0800 | [diff] [blame] | 418 | static bool supports_ble_2m_phy(void) { |
| 419 | CHECK(readable); |
| 420 | CHECK(ble_supported); |
| 421 | return HCI_LE_2M_PHY_SUPPORTED(features_ble.as_array); |
| 422 | } |
| 423 | |
| 424 | static bool supports_ble_coded_phy(void) { |
| 425 | CHECK(readable); |
| 426 | CHECK(ble_supported); |
| 427 | return HCI_LE_CODED_PHY_SUPPORTED(features_ble.as_array); |
| 428 | } |
| 429 | |
Jakub Pawlowski | 1f4cc6d | 2016-11-28 11:16:04 -0800 | [diff] [blame] | 430 | static bool supports_ble_extended_advertising(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 431 | CHECK(readable); |
| 432 | CHECK(ble_supported); |
Jakub Pawlowski | 1f4cc6d | 2016-11-28 11:16:04 -0800 | [diff] [blame] | 433 | return HCI_LE_EXTENDED_ADVERTISING_SUPPORTED(features_ble.as_array); |
| 434 | } |
| 435 | |
| 436 | static bool supports_ble_periodic_advertising(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 437 | CHECK(readable); |
| 438 | CHECK(ble_supported); |
Jakub Pawlowski | 1f4cc6d | 2016-11-28 11:16:04 -0800 | [diff] [blame] | 439 | return HCI_LE_PERIODIC_ADVERTISING_SUPPORTED(features_ble.as_array); |
| 440 | } |
| 441 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 442 | static uint16_t get_acl_data_size_classic(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 443 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 444 | return acl_data_size_classic; |
| 445 | } |
| 446 | |
| 447 | static uint16_t get_acl_data_size_ble(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 448 | CHECK(readable); |
| 449 | CHECK(ble_supported); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 450 | return acl_data_size_ble; |
| 451 | } |
| 452 | |
| 453 | static uint16_t get_acl_packet_size_classic(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 454 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 455 | return acl_data_size_classic + HCI_DATA_PREAMBLE_SIZE; |
| 456 | } |
| 457 | |
| 458 | static uint16_t get_acl_packet_size_ble(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 459 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 460 | return acl_data_size_ble + HCI_DATA_PREAMBLE_SIZE; |
| 461 | } |
| 462 | |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 463 | static uint16_t get_ble_suggested_default_data_length(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 464 | CHECK(readable); |
| 465 | CHECK(ble_supported); |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 466 | return ble_suggested_default_data_length; |
| 467 | } |
| 468 | |
Jakub Pawlowski | 4f0c5b5 | 2018-02-02 22:05:11 -0800 | [diff] [blame] | 469 | static uint16_t get_ble_maximum_tx_data_length(void) { |
| 470 | CHECK(readable); |
| 471 | CHECK(ble_supported); |
| 472 | return ble_supported_max_tx_octets; |
| 473 | } |
| 474 | |
Jakub Pawlowski | 1f4cc6d | 2016-11-28 11:16:04 -0800 | [diff] [blame] | 475 | static uint16_t get_ble_maxium_advertising_data_length(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 476 | CHECK(readable); |
| 477 | CHECK(ble_supported); |
Jakub Pawlowski | 1f4cc6d | 2016-11-28 11:16:04 -0800 | [diff] [blame] | 478 | return ble_maxium_advertising_data_length; |
| 479 | } |
| 480 | |
| 481 | static uint8_t get_ble_number_of_supported_advertising_sets(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 482 | CHECK(readable); |
| 483 | CHECK(ble_supported); |
Jakub Pawlowski | 1f4cc6d | 2016-11-28 11:16:04 -0800 | [diff] [blame] | 484 | return ble_number_of_supported_advertising_sets; |
| 485 | } |
| 486 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 487 | static uint16_t get_acl_buffer_count_classic(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 488 | CHECK(readable); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 489 | return acl_buffer_count_classic; |
| 490 | } |
| 491 | |
| 492 | static uint8_t get_acl_buffer_count_ble(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 493 | CHECK(readable); |
| 494 | CHECK(ble_supported); |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 495 | return acl_buffer_count_ble; |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 496 | } |
| 497 | |
Priti Aghera | b8b3e80 | 2015-04-17 18:11:24 -0700 | [diff] [blame] | 498 | static uint8_t get_ble_white_list_size(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 499 | CHECK(readable); |
| 500 | CHECK(ble_supported); |
Priti Aghera | b8b3e80 | 2015-04-17 18:11:24 -0700 | [diff] [blame] | 501 | return ble_white_list_size; |
| 502 | } |
| 503 | |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 504 | static uint8_t get_ble_resolving_list_max_size(void) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 505 | CHECK(readable); |
| 506 | CHECK(ble_supported); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 507 | return ble_resolving_list_max_size; |
| 508 | } |
| 509 | |
| 510 | 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] | 511 | // Setting "resolving_list_max_size" to 0 is done during cleanup, |
| 512 | // hence we ignore the "readable" flag already set to false during shutdown. |
| 513 | if (resolving_list_max_size != 0) { |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 514 | CHECK(readable); |
Pavlin Radoslavov | 58318f4 | 2016-05-05 16:20:15 -0700 | [diff] [blame] | 515 | } |
Jack He | f2af1c4 | 2016-12-13 01:59:12 -0800 | [diff] [blame] | 516 | CHECK(ble_supported); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 517 | ble_resolving_list_max_size = resolving_list_max_size; |
| 518 | } |
| 519 | |
Jakub Pawlowski | 96fb273 | 2017-03-24 17:52:02 -0700 | [diff] [blame] | 520 | static uint8_t get_le_all_initiating_phys() { |
| 521 | uint8_t phy = PHY_LE_1M; |
| 522 | // TODO(jpawlowski): uncomment after next FW udpate |
| 523 | // if (supports_ble_2m_phy()) phy |= PHY_LE_2M; |
| 524 | // if (supports_ble_coded_phy()) phy |= PHY_LE_CODED; |
| 525 | return phy; |
| 526 | } |
| 527 | |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 528 | static const controller_t interface = { |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 529 | get_is_ready, |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 530 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 531 | get_address, |
| 532 | get_bt_version, |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 533 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 534 | get_features_classic, |
| 535 | get_last_features_classic_index, |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 536 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 537 | get_features_ble, |
| 538 | get_ble_supported_states, |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 539 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 540 | supports_simple_pairing, |
| 541 | supports_secure_connections, |
| 542 | supports_simultaneous_le_bredr, |
| 543 | supports_reading_remote_extended_features, |
| 544 | supports_interlaced_inquiry_scan, |
| 545 | supports_rssi_with_inquiry_results, |
| 546 | supports_extended_inquiry_response, |
| 547 | supports_master_slave_role_switch, |
Mudumba Ananth | 57f6508 | 2017-02-09 09:05:48 -0800 | [diff] [blame] | 548 | supports_enhanced_setup_synchronous_connection, |
| 549 | supports_enhanced_accept_synchronous_connection, |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 550 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 551 | supports_ble, |
| 552 | supports_ble_packet_extension, |
| 553 | supports_ble_connection_parameters_request, |
| 554 | supports_ble_privacy, |
Jakub Pawlowski | ba78601 | 2017-06-26 11:26:46 -0700 | [diff] [blame] | 555 | supports_ble_set_privacy_mode, |
Jakub Pawlowski | 4b1feb6 | 2017-03-09 18:11:43 -0800 | [diff] [blame] | 556 | supports_ble_2m_phy, |
| 557 | supports_ble_coded_phy, |
Jakub Pawlowski | 1f4cc6d | 2016-11-28 11:16:04 -0800 | [diff] [blame] | 558 | supports_ble_extended_advertising, |
| 559 | supports_ble_periodic_advertising, |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 560 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 561 | get_acl_data_size_classic, |
| 562 | get_acl_data_size_ble, |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 563 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 564 | get_acl_packet_size_classic, |
| 565 | get_acl_packet_size_ble, |
| 566 | get_ble_suggested_default_data_length, |
Jakub Pawlowski | 4f0c5b5 | 2018-02-02 22:05:11 -0800 | [diff] [blame] | 567 | get_ble_maximum_tx_data_length, |
Jakub Pawlowski | 1f4cc6d | 2016-11-28 11:16:04 -0800 | [diff] [blame] | 568 | get_ble_maxium_advertising_data_length, |
| 569 | get_ble_number_of_supported_advertising_sets, |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 570 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 571 | get_acl_buffer_count_classic, |
| 572 | get_acl_buffer_count_ble, |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 573 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 574 | get_ble_white_list_size, |
Priti Aghera | b8b3e80 | 2015-04-17 18:11:24 -0700 | [diff] [blame] | 575 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 576 | get_ble_resolving_list_max_size, |
| 577 | set_ble_resolving_list_max_size, |
Jakub Pawlowski | 96fb273 | 2017-03-24 17:52:02 -0700 | [diff] [blame] | 578 | get_local_supported_codecs, |
| 579 | get_le_all_initiating_phys}; |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 580 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 581 | const controller_t* controller_get_interface() { |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 582 | static bool loaded = false; |
| 583 | if (!loaded) { |
| 584 | loaded = true; |
| 585 | |
| 586 | hci = hci_layer_get_interface(); |
| 587 | packet_factory = hci_packet_factory_get_interface(); |
| 588 | packet_parser = hci_packet_parser_get_interface(); |
| 589 | } |
| 590 | |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 591 | return &interface; |
| 592 | } |
| 593 | |
Myles Watson | 4451b3b | 2016-11-09 10:20:44 -0800 | [diff] [blame] | 594 | const controller_t* controller_get_test_interface( |
| 595 | const hci_t* hci_interface, |
| 596 | const hci_packet_factory_t* packet_factory_interface, |
| 597 | const hci_packet_parser_t* packet_parser_interface) { |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 598 | hci = hci_interface; |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 599 | packet_factory = packet_factory_interface; |
| 600 | packet_parser = packet_parser_interface; |
| 601 | return &interface; |
| 602 | } |