• 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 #pragma once
20 
21 #include <stdbool.h>
22 #include <stdint.h>
23 
24 #include "btcore/include/device_features.h"
25 #include "hci/include/hci_layer.h"
26 #include "hci/include/hci_packet_factory.h"
27 #include "hci/include/hci_packet_parser.h"
28 
29 static const char CONTROLLER_MODULE[] = "controller_module";
30 
31 typedef struct controller_t {
32   bool (*get_is_ready)(void);
33 
34   const RawAddress* (*get_address)(void);
35   const bt_version_t* (*get_bt_version)(void);
36 
37   const uint8_t* (*get_ble_supported_states)(void);
38 
39   bool (*supports_simple_pairing)(void);
40   bool (*supports_secure_connections)(void);
41   bool (*supports_simultaneous_le_bredr)(void);
42   bool (*supports_reading_remote_extended_features)(void);
43   bool (*supports_interlaced_inquiry_scan)(void);
44   bool (*supports_rssi_with_inquiry_results)(void);
45   bool (*supports_extended_inquiry_response)(void);
46   bool (*supports_central_peripheral_role_switch)(void);
47   bool (*supports_enhanced_setup_synchronous_connection)(void);
48   bool (*supports_enhanced_accept_synchronous_connection)(void);
49   bool (*supports_3_slot_packets)(void);
50   bool (*supports_5_slot_packets)(void);
51   bool (*supports_classic_2m_phy)(void);
52   bool (*supports_classic_3m_phy)(void);
53   bool (*supports_3_slot_edr_packets)(void);
54   bool (*supports_5_slot_edr_packets)(void);
55   bool (*supports_sco)(void);
56   bool (*supports_hv2_packets)(void);
57   bool (*supports_hv3_packets)(void);
58   bool (*supports_ev3_packets)(void);
59   bool (*supports_ev4_packets)(void);
60   bool (*supports_ev5_packets)(void);
61   bool (*supports_esco_2m_phy)(void);
62   bool (*supports_esco_3m_phy)(void);
63   bool (*supports_3_slot_esco_edr_packets)(void);
64   bool (*supports_role_switch)(void);
65   bool (*supports_hold_mode)(void);
66   bool (*supports_sniff_mode)(void);
67   bool (*supports_park_mode)(void);
68   bool (*supports_non_flushable_pb)(void);
69   bool (*supports_sniff_subrating)(void);
70   bool (*supports_encryption_pause)(void);
71 
72   bool (*supports_ble)(void);
73   bool (*supports_ble_packet_extension)(void);
74   bool (*supports_ble_connection_parameters_request)(void);
75   bool (*supports_ble_privacy)(void);
76   bool (*supports_ble_set_privacy_mode)(void);
77   bool (*supports_ble_2m_phy)(void);
78   bool (*supports_ble_coded_phy)(void);
79   bool (*supports_ble_extended_advertising)(void);
80   bool (*supports_ble_periodic_advertising)(void);
81   bool (*supports_ble_peripheral_initiated_feature_exchange)(void);
82   bool (*supports_ble_connection_parameter_request)(void);
83   bool (*supports_ble_periodic_advertising_sync_transfer_sender)(void);
84   bool (*supports_ble_periodic_advertising_sync_transfer_recipient)(void);
85   bool (*supports_ble_connected_isochronous_stream_central)(void);
86   bool (*supports_ble_connected_isochronous_stream_peripheral)(void);
87   bool (*supports_ble_isochronous_broadcaster)(void);
88   bool (*supports_ble_synchronized_receiver)(void);
89 
90   // Get the cached acl data sizes for the controller.
91   uint16_t (*get_acl_data_size_classic)(void);
92   uint16_t (*get_acl_data_size_ble)(void);
93   uint16_t (*get_iso_data_size)(void);
94 
95   // Get the cached acl packet sizes for the controller.
96   // This is a convenience function for the respective
97   // acl data size + size of the acl header.
98   uint16_t (*get_acl_packet_size_classic)(void);
99   uint16_t (*get_acl_packet_size_ble)(void);
100   uint16_t (*get_iso_packet_size)(void);
101 
102   uint16_t (*get_ble_default_data_packet_length)(void);
103   uint16_t (*get_ble_maximum_tx_data_length)(void);
104   uint16_t (*get_ble_maximum_tx_time)(void);
105   uint16_t (*get_ble_maxium_advertising_data_length)(void);
106   uint8_t (*get_ble_number_of_supported_advertising_sets)(void);
107   uint8_t (*get_ble_periodic_advertiser_list_size)(void);
108 
109   // Get the number of acl packets the controller can buffer.
110   uint16_t (*get_acl_buffer_count_classic)(void);
111   uint8_t (*get_acl_buffer_count_ble)(void);
112   uint8_t (*get_iso_buffer_count)(void);
113 
114   uint8_t (*get_ble_acceptlist_size)(void);
115 
116   uint8_t (*get_ble_resolving_list_max_size)(void);
117   void (*set_ble_resolving_list_max_size)(int resolving_list_max_size);
118   uint8_t* (*get_local_supported_codecs)(uint8_t* number_of_codecs);
119   uint8_t (*get_le_all_initiating_phys)(void);
120 
121 } controller_t;
122 
123 const controller_t* controller_get_interface();
124 
125 const controller_t* controller_get_test_interface(
126     const hci_t* hci_interface,
127     const hci_packet_factory_t* packet_factory_interface,
128     const hci_packet_parser_t* packet_parser_interface);
129