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
17 #include "stack/include/btm_client_interface.h"
18 #include <cstdint>
19 #include "main/shim/btm_api.h"
20 #include "stack/include/acl_api.h"
21 #include "stack/include/btm_api.h"
22 #include "stack/include/btm_ble_api.h"
23 #include "stack/include/btm_client_interface.h"
24 #include "stack/include/hci_error_code.h"
25 #include "stack/include/hcidefs.h"
26 #include "types/bt_transport.h"
27 #include "types/raw_address.h"
28
29 struct btm_client_interface_s btm_client_interface = {
30 .lifecycle =
31 {
32 .BTM_GetHCIConnHandle = BTM_GetHCIConnHandle,
33 .BTM_PmRegister = BTM_PmRegister,
34 .BTM_VendorSpecificCommand = BTM_VendorSpecificCommand,
35 .ACL_RegisterClient = ACL_RegisterClient,
36 .ACL_UnregisterClient = ACL_UnregisterClient,
37 .btm_init = btm_init,
38 .btm_free = btm_free,
39 .btm_ble_init = btm_ble_init,
40 .btm_ble_free = btm_ble_free,
41 .BTM_reset_complete = BTM_reset_complete,
42 },
43
44 .scn =
45 {
46 .BTM_AllocateSCN = BTM_AllocateSCN,
47 .BTM_TryAllocateSCN = BTM_TryAllocateSCN,
48 .BTM_FreeSCN = BTM_FreeSCN,
49 },
50
51 .neighbor =
52 {
53 .BTM_CancelInquiry = BTM_CancelInquiry,
54 .BTM_ClearInqDb = BTM_ClearInqDb,
55 .BTM_InqDbNext = BTM_InqDbNext,
56 .BTM_SetConnectability = BTM_SetConnectability,
57 .BTM_SetDiscoverability = BTM_SetDiscoverability,
58 .BTM_StartInquiry = BTM_StartInquiry,
59 .BTM_IsInquiryActive = BTM_IsInquiryActive,
60 .BTM_SetInquiryMode = BTM_SetInquiryMode,
61 .BTM_EnableInterlacedInquiryScan = BTM_EnableInterlacedInquiryScan,
62 .BTM_EnableInterlacedPageScan = BTM_EnableInterlacedPageScan,
63 },
64
65 // Acl peer and lifecycle
66 .peer =
67 {
68 .features =
69 {
70 .SupportTransparentSynchronousData =
71 ACL_SupportTransparentSynchronousData,
72 },
73
74 .BTM_CancelRemoteDeviceName = BTM_CancelRemoteDeviceName,
75 .BTM_IsAclConnectionUp = BTM_IsAclConnectionUp,
76 .BTM_ReadConnectedTransportAddress =
77 BTM_ReadConnectedTransportAddress,
78 .BTM_ReadDevInfo = BTM_ReadDevInfo,
79 .BTM_ReadRemoteDeviceName = BTM_ReadRemoteDeviceName,
80 .BTM_ReadRemoteFeatures = BTM_ReadRemoteFeatures,
81 .BTM_GetMaxPacketSize = BTM_GetMaxPacketSize,
82 .BTM_ReadRemoteVersion = BTM_ReadRemoteVersion,
83 },
84
85 .link_policy =
86 {
87 .BTM_GetRole = BTM_GetRole,
88 .BTM_SetPowerMode = BTM_SetPowerMode,
89 .BTM_SetSsrParams = BTM_SetSsrParams,
90 .BTM_SwitchRoleToCentral = BTM_SwitchRoleToCentral,
91 .BTM_WritePageTimeout = BTM_WritePageTimeout,
92 .BTM_block_role_switch_for = BTM_block_role_switch_for,
93 .BTM_block_sniff_mode_for = BTM_block_sniff_mode_for,
94 .BTM_default_unblock_role_switch = BTM_default_unblock_role_switch,
95 .BTM_unblock_role_switch_for = BTM_unblock_role_switch_for,
96 .BTM_unblock_sniff_mode_for = BTM_unblock_sniff_mode_for,
97 },
98
99 .link_controller =
100 {
101 .BTM_GetLinkSuperTout = BTM_GetLinkSuperTout,
102 .BTM_ReadRSSI = BTM_ReadRSSI,
103 },
104
105 .security =
106 {
107 .BTM_ConfirmReqReply = BTM_ConfirmReqReply,
108 .BTM_PINCodeReply = BTM_PINCodeReply,
109 .BTM_RemoteOobDataReply = BTM_RemoteOobDataReply,
110 .BTM_SecAddBleDevice = BTM_SecAddBleDevice,
111 .BTM_SecAddBleKey = BTM_SecAddBleKey,
112 .BTM_SecAddDevice = BTM_SecAddDevice,
113 .BTM_SecAddRmtNameNotifyCallback = BTM_SecAddRmtNameNotifyCallback,
114 .BTM_SecBond = BTM_SecBond,
115 .BTM_SecBondCancel = BTM_SecBondCancel,
116 .BTM_SecClearSecurityFlags = BTM_SecClearSecurityFlags,
117 .BTM_SecClrService = BTM_SecClrService,
118 .BTM_SecClrServiceByPsm = BTM_SecClrServiceByPsm,
119 .BTM_SecDeleteDevice = BTM_SecDeleteDevice,
120 .BTM_SecDeleteRmtNameNotifyCallback =
121 BTM_SecDeleteRmtNameNotifyCallback,
122 .BTM_SecReadDevName = BTM_SecReadDevName,
123 .BTM_SecRegister = BTM_SecRegister,
124 .BTM_SetEncryption = BTM_SetEncryption,
125 .BTM_IsEncrypted = BTM_IsEncrypted,
126 .BTM_SecIsSecurityPending = BTM_SecIsSecurityPending,
127 .BTM_IsLinkKeyKnown = BTM_IsLinkKeyKnown,
128 },
129
130 .ble =
131 {
132 .BTM_BleConfirmReply = BTM_BleConfirmReply,
133 .BTM_BleGetEnergyInfo = BTM_BleGetEnergyInfo,
134 .BTM_BleLoadLocalKeys = BTM_BleLoadLocalKeys,
135 .BTM_BleObserve = BTM_BleObserve,
136 .BTM_BlePasskeyReply = BTM_BlePasskeyReply,
137 .BTM_BleReadControllerFeatures = BTM_BleReadControllerFeatures,
138 .BTM_BleSetPhy = BTM_BleSetPhy,
139 .BTM_BleSetPrefConnParams = BTM_BleSetPrefConnParams,
140 .BTM_SetBleDataLength = BTM_SetBleDataLength,
141 .BTM_UseLeLink = BTM_UseLeLink,
142 },
143
144 .sco =
145 {
146 .BTM_CreateSco = BTM_CreateSco,
147 .BTM_EScoConnRsp = BTM_EScoConnRsp,
148 .BTM_GetNumScoLinks = BTM_GetNumScoLinks,
149 .BTM_RegForEScoEvts = BTM_RegForEScoEvts,
150 .BTM_RemoveSco = BTM_RemoveSco,
151 .BTM_SetEScoMode = BTM_SetEScoMode,
152 .BTM_WriteVoiceSettings = BTM_WriteVoiceSettings,
153 },
154
155 .local =
156 {
157 .BTM_ReadLocalDeviceNameFromController =
158 BTM_ReadLocalDeviceNameFromController,
159 .BTM_SetDeviceClass = BTM_SetDeviceClass,
160 .BTM_SetLocalDeviceName = BTM_SetLocalDeviceName,
161 .BTM_IsDeviceUp = BTM_IsDeviceUp,
162 .BTM_ReadDeviceClass = BTM_ReadDeviceClass,
163 },
164
165 .eir =
166 {
167 .BTM_GetEirSupportedServices = BTM_GetEirSupportedServices,
168 .BTM_GetEirUuidList = BTM_GetEirUuidList,
169 .BTM_RemoveEirService = BTM_RemoveEirService,
170 .BTM_WriteEIR = BTM_WriteEIR,
171 },
172 .db =
173 {
174 .BTM_InqDbRead = BTM_InqDbRead,
175 .BTM_InqDbFirst = BTM_InqDbFirst,
176 .BTM_InqDbNext = BTM_InqDbNext,
177 .BTM_ClearInqDb = BTM_ClearInqDb,
178 },
179 };
180
get_btm_client_interface()181 struct btm_client_interface_s& get_btm_client_interface() {
182 return btm_client_interface;
183 }
184