1 /*
2 * Copyright 2021 HIMSA II K/S - www.himsa.com.
3 * Represented by EHIMA - www.ehima.com
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 #include "bta_gatt_api_mock.h"
19
20 static gatt::MockBtaGattInterface* gatt_interface = nullptr;
21
SetMockBtaGattInterface(MockBtaGattInterface * mock_bta_gatt_interface)22 void gatt::SetMockBtaGattInterface(
23 MockBtaGattInterface* mock_bta_gatt_interface) {
24 gatt_interface = mock_bta_gatt_interface;
25 }
26
BTA_GATTC_AppRegister(tBTA_GATTC_CBACK * p_client_cb,BtaAppRegisterCallback cb,bool eatt_support)27 void BTA_GATTC_AppRegister(tBTA_GATTC_CBACK* p_client_cb,
28 BtaAppRegisterCallback cb, bool eatt_support) {
29 gatt_interface->AppRegister(p_client_cb, cb, eatt_support);
30 }
31
BTA_GATTC_AppDeregister(tGATT_IF client_if)32 void BTA_GATTC_AppDeregister(tGATT_IF client_if) {
33 gatt_interface->AppDeregister(client_if);
34 }
35
BTA_GATTC_Open(tGATT_IF client_if,const RawAddress & remote_bda,bool is_direct,tBT_TRANSPORT transport,bool opportunistic)36 void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
37 bool is_direct, tBT_TRANSPORT transport,
38 bool opportunistic) {
39 gatt_interface->Open(client_if, remote_bda, is_direct, transport,
40 opportunistic);
41 }
42
BTA_GATTC_Open(tGATT_IF client_if,const RawAddress & remote_bda,bool is_direct,bool opportunistic)43 void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
44 bool is_direct, bool opportunistic) {
45 gatt_interface->Open(client_if, remote_bda, is_direct, opportunistic);
46 }
47
BTA_GATTC_CancelOpen(tGATT_IF client_if,const RawAddress & remote_bda,bool is_direct)48 void BTA_GATTC_CancelOpen(tGATT_IF client_if, const RawAddress& remote_bda,
49 bool is_direct) {
50 gatt_interface->CancelOpen(client_if, remote_bda, is_direct);
51 }
52
BTA_GATTC_Close(uint16_t conn_id)53 void BTA_GATTC_Close(uint16_t conn_id) { gatt_interface->Close(conn_id); }
54
BTA_GATTC_ServiceSearchRequest(uint16_t conn_id,const bluetooth::Uuid * p_srvc_uuid)55 void BTA_GATTC_ServiceSearchRequest(uint16_t conn_id,
56 const bluetooth::Uuid* p_srvc_uuid) {
57 gatt_interface->ServiceSearchRequest(conn_id, p_srvc_uuid);
58 }
59
BTA_GATTC_GetServices(uint16_t conn_id)60 const std::list<gatt::Service>* BTA_GATTC_GetServices(uint16_t conn_id) {
61 return gatt_interface->GetServices(conn_id);
62 }
63
BTA_GATTC_GetCharacteristic(uint16_t conn_id,uint16_t handle)64 const gatt::Characteristic* BTA_GATTC_GetCharacteristic(uint16_t conn_id,
65 uint16_t handle) {
66 return gatt_interface->GetCharacteristic(conn_id, handle);
67 }
68
BTA_GATTC_GetOwningService(uint16_t conn_id,uint16_t handle)69 const gatt::Service* BTA_GATTC_GetOwningService(uint16_t conn_id,
70 uint16_t handle) {
71 return gatt_interface->GetOwningService(conn_id, handle);
72 }
73
BTA_GATTC_RegisterForNotifications(tGATT_IF client_if,const RawAddress & remote_bda,uint16_t handle)74 tGATT_STATUS BTA_GATTC_RegisterForNotifications(tGATT_IF client_if,
75 const RawAddress& remote_bda,
76 uint16_t handle) {
77 return gatt_interface->RegisterForNotifications(client_if, remote_bda,
78 handle);
79 }
80
BTA_GATTC_DeregisterForNotifications(tGATT_IF client_if,const RawAddress & remote_bda,uint16_t handle)81 tGATT_STATUS BTA_GATTC_DeregisterForNotifications(tGATT_IF client_if,
82 const RawAddress& remote_bda,
83 uint16_t handle) {
84 return gatt_interface->DeregisterForNotifications(client_if, remote_bda,
85 handle);
86 }
87