1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "stack/include/btm_client_interface.h"
17 
18 #include <bluetooth/log.h>
19 
20 #include "security_client_callbacks.h"
21 #include "stack/btm/btm_ble_int.h"
22 #include "stack/include/acl_api.h"
23 #include "stack/include/btm_ble_api.h"
24 
25 struct btm_client_interface_t btm_client_interface = {
26         .lifecycle =
27                 {
28                         .BTM_PmRegister = ::BTM_PmRegister,
29                         .ACL_RegisterClient = ::ACL_RegisterClient,
30                         .ACL_UnregisterClient = ::ACL_UnregisterClient,
31                         .btm_init = ::btm_init,
32                         .btm_free = ::btm_free,
33                         .btm_ble_init = ::btm_ble_init,
34                         .btm_ble_free = ::btm_ble_free,
35                         .BTM_reset_complete = ::BTM_reset_complete,
36                 },
37 
38         // Acl peer and lifecycle
39         .peer =
40                 {
41                         .BTM_IsAclConnectionUp = ::BTM_IsAclConnectionUp,
42                         .BTM_ReadConnectedTransportAddress = ::BTM_ReadConnectedTransportAddress,
43                         .BTM_ReadRemoteFeatures = ::BTM_ReadRemoteFeatures,
44                         .BTM_ReadDevInfo = ::BTM_ReadDevInfo,
45                         .BTM_GetMaxPacketSize = ::BTM_GetMaxPacketSize,
46                         .BTM_ReadRemoteVersion = ::BTM_ReadRemoteVersion,
47                         .BTM_GetPeerDeviceTypeFromFeatures = ::BTM_GetPeerDeviceTypeFromFeatures,
48                         .BTM_RequestPeerSCA = ::BTM_RequestPeerSCA,
49                         .BTM_GetPeerSCA = ::BTM_GetPeerSCA,
50                         .BTM_IsPhy2mSupported = ::BTM_IsPhy2mSupported,
51                         .BTM_GetHCIConnHandle = ::BTM_GetHCIConnHandle,
52                         .BTM_IsAclConnectionUpAndHandleValid =
53                                 ::BTM_IsAclConnectionUpAndHandleValid,
54                 },
55 
56         .link_policy =
57                 {
58                         .BTM_GetRole = ::BTM_GetRole,
59                         .BTM_SetPowerMode = ::BTM_SetPowerMode,
60                         .BTM_SetSsrParams = ::BTM_SetSsrParams,
61                         .BTM_SwitchRoleToCentral = ::BTM_SwitchRoleToCentral,
62                         .BTM_block_role_switch_for = ::BTM_block_role_switch_for,
63                         .BTM_block_sniff_mode_for = ::BTM_block_sniff_mode_for,
64                         .BTM_default_unblock_role_switch = ::BTM_default_unblock_role_switch,
65                         .BTM_unblock_role_switch_for = ::BTM_unblock_role_switch_for,
66                         .BTM_unblock_sniff_mode_for = ::BTM_unblock_sniff_mode_for,
67                         .BTM_WritePageTimeout = ::BTM_WritePageTimeout,
68                 },
69 
70         .link_controller =
71                 {
72                         .BTM_GetLinkSuperTout = ::BTM_GetLinkSuperTout,
73                         .BTM_ReadRSSI = ::BTM_ReadRSSI,
74                 },
75 
76         .security = get_security_client_interface(),
77 
78         .ble =
79                 {
80                         .BTM_BleGetEnergyInfo = ::BTM_BleGetEnergyInfo,
81                         .BTM_BleObserve = ::BTM_BleObserve,
82                         .BTM_SetBleDataLength = ::BTM_SetBleDataLength,
83                         .BTM_BleReadControllerFeatures = ::BTM_BleReadControllerFeatures,
84                         .BTM_BleSetPhy = ::BTM_BleSetPhy,
85                         .BTM_BleSetPrefConnParams = ::BTM_BleSetPrefConnParams,
86                         .BTM_UseLeLink = ::BTM_UseLeLink,
87                         .BTM_IsRemoteVersionReceived = ::BTM_IsRemoteVersionReceived,
88                         .BTM_SetConsolidationCallback = ::BTM_SetConsolidationCallback,
89                 },
90 
91         .sco =
92                 {
93                         .BTM_CreateSco = ::BTM_CreateSco,
94                         .BTM_RegForEScoEvts = ::BTM_RegForEScoEvts,
95                         .BTM_RemoveSco = ::BTM_RemoveSco,
96                         .BTM_RemoveScoByBdaddr = ::BTM_RemoveScoByBdaddr,
97                         .BTM_WriteVoiceSettings = ::BTM_WriteVoiceSettings,
98                         .BTM_EScoConnRsp = ::BTM_EScoConnRsp,
99                         .BTM_GetNumScoLinks = ::BTM_GetNumScoLinks,
100                         .BTM_SetEScoMode = ::BTM_SetEScoMode,
101                         .BTM_GetScoDebugDump = ::BTM_GetScoDebugDump,
102                         .BTM_IsScoActiveByBdaddr = ::BTM_IsScoActiveByBdaddr,
103                 },
104 
105         .local =
106                 {
107                         .BTM_ReadLocalDeviceName = ::BTM_ReadLocalDeviceName,
108                         .BTM_SetLocalDeviceName = ::BTM_SetLocalDeviceName,
109                         .BTM_SetDeviceClass = ::BTM_SetDeviceClass,
110                         .BTM_IsDeviceUp = ::BTM_IsDeviceUp,
111                         .BTM_ReadDeviceClass = ::BTM_ReadDeviceClass,
112                 },
113 
114         .eir =
115                 {
116                         .BTM_WriteEIR = ::BTM_WriteEIR,
117                         .BTM_GetEirSupportedServices = ::BTM_GetEirSupportedServices,
118                         .BTM_GetEirUuidList = ::BTM_GetEirUuidList,
119                         .BTM_AddEirService = ::BTM_AddEirService,
120                         .BTM_RemoveEirService = ::BTM_RemoveEirService,
121                 },
122         .db =
123                 {
124                         .BTM_InqDbRead = ::BTM_InqDbRead,
125                         .BTM_InqDbFirst = ::BTM_InqDbFirst,
126                         .BTM_InqDbNext = ::BTM_InqDbNext,
127                         .BTM_ClearInqDb = ::BTM_ClearInqDb,
128                 },
129         .vendor =
130                 {
131                         .BTM_VendorSpecificCommand = ::BTM_VendorSpecificCommand,
132                 },
133 };
134 
get_btm_client_interface()135 struct btm_client_interface_t& get_btm_client_interface() { return btm_client_interface; }
136