1 /* 2 * Copyright 2023 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 #pragma once 18 19 #include <cstdint> 20 #include <string> 21 22 #include "bta/include/bta_gatt_api.h" 23 #include "gd/common/circular_buffer.h" 24 #include "include/hardware/bt_common_types.h" 25 #include "stack/include/btm_ble_api_types.h" 26 #include "types/bluetooth/uuid.h" 27 #include "types/raw_address.h" 28 29 // 30 // Interface as a GATT client for bta clients 31 // 32 struct gatt_interface_t { 33 void (*BTA_GATTC_CancelOpen)(tGATT_IF client_if, const RawAddress& remote_bda, bool is_direct); 34 void (*BTA_GATTC_Refresh)(const RawAddress& remote_bda); 35 void (*BTA_GATTC_GetGattDb)(tCONN_ID conn_id, uint16_t start_handle, uint16_t end_handle, 36 btgatt_db_element_t** db, int* count); 37 void (*BTA_GATTC_AppRegister)(const std::string& name, tBTA_GATTC_CBACK* p_client_cb, 38 BtaAppRegisterCallback cb, bool eatt_support); 39 void (*BTA_GATTC_Close)(tCONN_ID conn_id); 40 void (*BTA_GATTC_ServiceSearchRequest)(tCONN_ID conn_id, const bluetooth::Uuid* p_srvc_uuid); 41 void (*BTA_GATTC_Open)(tGATT_IF client_if, const RawAddress& remote_bda, 42 tBTM_BLE_CONN_TYPE connection_type, bool opportunistic, 43 uint16_t preferred_mtu); 44 }; 45 46 // 47 // Returns the current GATT client interface 48 // 49 gatt_interface_t& get_gatt_interface(); 50 51 // 52 // Appends a callback entry into GATT client API/callback history 53 // 54 void gatt_history_callback(const std::string& entry); 55 56 // 57 // Dumps the GATT client API/callback history to dumpsys 58 // 59 void DumpsysBtaDmGattClient(int fd); 60 61 namespace bluetooth::testing { 62 std::vector<bluetooth::common::TimestampedEntry<std::string>> PullCopyOfGattHistory(); 63 } // namespace bluetooth::testing 64