btif_gatt_client.cc revision c171ac407cfc6d30a11af6b12ead39688eb897f7
1ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/****************************************************************************** 2ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * 3c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji * Copyright (C) 2009-2014 Broadcom Corporation 4ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * 5ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * Licensed under the Apache License, Version 2.0 (the "License"); 6ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * you may not use this file except in compliance with the License. 7ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * You may obtain a copy of the License at: 8ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * 9ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * http://www.apache.org/licenses/LICENSE-2.0 10ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * 11ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * Unless required by applicable law or agreed to in writing, software 12ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * distributed under the License is distributed on an "AS IS" BASIS, 13ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * See the License for the specific language governing permissions and 15ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * limitations under the License. 16ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * 17ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ******************************************************************************/ 18ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 19ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/******************************************************************************* 20ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * 21ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * Filename: btif_gatt_client.c 22ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * 23ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * Description: GATT client implementation 24ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * 25ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta *******************************************************************************/ 26ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2749120dc867c7818511b5afec461dfc97d17eef58Marie Janssen#define LOG_TAG "bt_btif_gattc" 2849120dc867c7818511b5afec461dfc97d17eef58Marie Janssen 29140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowski#include <base/at_exit.h> 30140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowski#include <base/bind.h> 31140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowski#include <base/threading/thread.h> 3249a86709488e5cfd5e23759da18bf9613e15b04dMarie Janssen#include <errno.h> 33ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include <hardware/bluetooth.h> 34ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include <stdio.h> 35ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include <stdlib.h> 36ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include <string.h> 376ed1548be2295fc1bec14f10cd0fade4f63daa6aSatya Calloji#include "device/include/controller.h" 386ed1548be2295fc1bec14f10cd0fade4f63daa6aSatya Calloji 39ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 4095b74f252f534ec757aab1fc08e086e02b2cfe8dSharvil Nanavati#include "btcore/include/bdaddr.h" 41ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_common.h" 42ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_util.h" 43ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 44ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 45ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 466975b4d711142b885af479721cada448952c6b41Andre Eisenbach#include <hardware/bt_gatt.h> 47db554581079863974af8e1289646f5deea6fc044Marie Janssen 48ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "bta_api.h" 49ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "bta_gatt_api.h" 50ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_config.h" 51db554581079863974af8e1289646f5deea6fc044Marie Janssen#include "btif_dm.h" 52ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_gatt.h" 53db554581079863974af8e1289646f5deea6fc044Marie Janssen#include "btif_gatt_multi_adv_util.h" 54ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_gatt_util.h" 55ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_storage.h" 56db554581079863974af8e1289646f5deea6fc044Marie Janssen#include "btif_storage.h" 5744802768c447ab480d4227b3a852a97d923b816dSharvil Nanavati#include "osi/include/log.h" 58b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach#include "vendor_api.h" 59b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach 60140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowskiusing base::Bind; 61140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowskiusing base::Owned; 62140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowski 63140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowskiextern bt_status_t do_in_jni_thread(const base::Closure& task); 64140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowski 65ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/******************************************************************************* 66ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Constants & Macros 67ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta********************************************************************************/ 68ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 69da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski#define CLI_CBACK_IN_JNI(P_CBACK, ...) \ 70da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski if (bt_gatt_callbacks && bt_gatt_callbacks->client->P_CBACK) { \ 71da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski BTIF_TRACE_API("HAL bt_gatt_callbacks->client->%s", #P_CBACK); \ 72da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski do_in_jni_thread(Bind(bt_gatt_callbacks->client->P_CBACK, __VA_ARGS__)); \ 73da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski } else { \ 74da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski ASSERTC(0, "Callback is NULL", 0); \ 75da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski } 76da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski 77ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#define CHECK_BTGATT_INIT() if (bt_gatt_callbacks == NULL)\ 78ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta {\ 79db554581079863974af8e1289646f5deea6fc044Marie Janssen LOG_WARN(LOG_TAG, "%s: BTGATT not initialized", __FUNCTION__);\ 80ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return BT_STATUS_NOT_READY;\ 81ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } else {\ 82db554581079863974af8e1289646f5deea6fc044Marie Janssen LOG_VERBOSE(LOG_TAG, "%s", __FUNCTION__);\ 83ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 84ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 85a1e649b2566040d1f9e620753f18ca1fc088c64fAndre Eisenbach#define BLE_RESOLVE_ADDR_MSB 0x40 /* bit7, bit6 is 01 to be resolvable random */ 86a1e649b2566040d1f9e620753f18ca1fc088c64fAndre Eisenbach#define BLE_RESOLVE_ADDR_MASK 0xc0 /* bit 6, and bit7 */ 87a1e649b2566040d1f9e620753f18ca1fc088c64fAndre Eisenbach#define BTM_BLE_IS_RESOLVE_BDA(x) ((x[0] & BLE_RESOLVE_ADDR_MASK) == BLE_RESOLVE_ADDR_MSB) 88ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 89ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#define BTIF_GATT_MAX_OBSERVED_DEV 40 90ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 91ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#define BTIF_GATT_OBSERVE_EVT 0x1000 92979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach#define BTIF_GATTC_SCAN_FILTER_EVT 0x1003 93ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 94c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji#define ENABLE_BATCH_SCAN 1 95c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji#define DISABLE_BATCH_SCAN 0 96c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 97ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/******************************************************************************* 98ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Local type definitions 99ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta********************************************************************************/ 100c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Callojitypedef struct 101c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji{ 102c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint8_t report_format; 103c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint16_t data_len; 104c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint8_t num_records; 105c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint8_t *p_rep_data; 106c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji} btgatt_batch_reports; 107c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 108c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Callojitypedef struct 109c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji{ 110c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint8_t status; 111c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint8_t client_if; 1121acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji uint8_t action; 1131acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji uint8_t avbl_space; 1141acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji uint8_t lost_timeout; 115f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji tBLE_ADDR_TYPE addr_type; 116c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint8_t batch_scan_full_max; 117c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint8_t batch_scan_trunc_max; 118c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint8_t batch_scan_notify_threshold; 119979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach tBTA_BLE_BATCH_SCAN_MODE scan_mode; 120c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint32_t scan_interval; 121c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint32_t scan_window; 122c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji tBTA_BLE_DISCARD_RULE discard_rule; 123f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji btgatt_batch_reports read_reports; 124c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji} btgatt_batch_track_cb_t; 125ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1261a9247a1229aa65b3d1dce16426177bc5828e54dSatya Callojitypedef tBTA_DM_BLE_PF_FILT_PARAMS btgatt_adv_filt_param_t; 1271a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji 1281a9247a1229aa65b3d1dce16426177bc5828e54dSatya Callojitypedef struct 1291a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji{ 1301a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint8_t client_if; 1311a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint8_t action; 1321a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji tBTA_DM_BLE_PF_COND_TYPE filt_type; 1331a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji bt_bdaddr_t bd_addr; 1341a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint8_t value[BTGATT_MAX_ATTR_LEN]; 1351a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint8_t value_len; 1361a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint8_t filt_index; 1371a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint16_t conn_id; 1381a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint16_t company_id_mask; 1391a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji bt_uuid_t uuid; 1401a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji bt_uuid_t uuid_mask; 1411a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint8_t value_mask[BTGATT_MAX_ATTR_LEN]; 1421a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint8_t value_mask_len; 1431a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint8_t has_mask; 1441a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint8_t addr_type; 1451a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji uint8_t status; 1461a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji tBTA_DM_BLE_PF_AVBL_SPACE avbl_space; 1471a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji tBTA_DM_BLE_SCAN_COND_OP cond_op; 1481a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji btgatt_adv_filt_param_t adv_filt_param; 1491a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji} btgatt_adv_filter_cb_t; 1501a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji 151ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battatypedef struct 152ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 153ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t value[BTGATT_MAX_ATTR_LEN]; 154a6ce7751d84218c193eb90d390aef23217b1737eWei Wang uint8_t inst_id; 155ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bd_addr; 156ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btgatt_srvc_id_t srvc_id; 157ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btgatt_srvc_id_t incl_srvc_id; 1585f9c140d094ebf4a269cdc6ae083900bf25f7faeAndre Eisenbach btgatt_gatt_id_t char_id; 1595f9c140d094ebf4a269cdc6ae083900bf25f7faeAndre Eisenbach btgatt_gatt_id_t descr_id; 1609dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski uint16_t handle; 161ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_uuid_t uuid; 162b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach bt_uuid_t uuid_mask; 163ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint16_t conn_id; 164ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint16_t len; 165b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach uint16_t mask; 166979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach uint32_t scan_interval; 167979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach uint32_t scan_window; 168ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t client_if; 169ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t action; 170ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t is_direct; 171ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t search_all; 172ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t auth_req; 173ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t write_type; 174ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t status; 175ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t addr_type; 1765c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach uint8_t start; 177b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach uint8_t has_mask; 178ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int8_t rssi; 1797fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta uint8_t flag; 180ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta tBT_DEVICE_TYPE device_type; 1817fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta btgatt_transport_t transport; 182ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} __attribute__((packed)) btif_gattc_cb_t; 183ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 184ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battatypedef struct 185ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 186ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bd_addr; 18752a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach uint16_t min_interval; 18852a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach uint16_t max_interval; 18952a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach uint16_t timeout; 19052a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach uint16_t latency; 19152a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach} btif_conn_param_cb_t; 19252a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach 19352a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbachtypedef struct 19452a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach{ 19552a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach bt_bdaddr_t bd_addr; 196ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BOOLEAN in_use; 197ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta}__attribute__((packed)) btif_gattc_dev_t; 198ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 199ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battatypedef struct 200ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 201ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_dev_t remote_dev[BTIF_GATT_MAX_OBSERVED_DEV]; 2027fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta uint8_t addr_type; 2037fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta uint8_t next_storage_idx; 204ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta}__attribute__((packed)) btif_gattc_dev_cb_t; 205ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 206ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/******************************************************************************* 207ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Static variables 208ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta********************************************************************************/ 209ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 210ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battaextern const btgatt_callbacks_t *bt_gatt_callbacks; 211ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic btif_gattc_dev_cb_t btif_gattc_dev_cb; 212ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic btif_gattc_dev_cb_t *p_dev_cb = &btif_gattc_dev_cb; 213ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic uint8_t rssi_request_client_if; 214ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 215ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/******************************************************************************* 216ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Static functions 217ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta********************************************************************************/ 218ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2199dd5a9c11f2022fa9709f0c34f04560c21105152Andre Eisenbachstatic bt_status_t btif_gattc_multi_adv_disable(int client_if); 22078bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavovstatic void btif_multi_adv_stop_cb(void *data) 2219dd5a9c11f2022fa9709f0c34f04560c21105152Andre Eisenbach{ 22278bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov int client_if = PTR_TO_INT(data); 2239dd5a9c11f2022fa9709f0c34f04560c21105152Andre Eisenbach btif_gattc_multi_adv_disable(client_if); // Does context switch 2249dd5a9c11f2022fa9709f0c34f04560c21105152Andre Eisenbach} 2259dd5a9c11f2022fa9709f0c34f04560c21105152Andre Eisenbach 226979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbachstatic btgattc_error_t btif_gattc_translate_btm_status(tBTM_STATUS status) 227979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach{ 228979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach switch(status) 229979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach { 230979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_SUCCESS: 231979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_SUCCESS_NO_SECURITY: 232979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_COMMAND_SUCCESS; 233979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 234979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_CMD_STARTED: 235979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_COMMAND_STARTED; 236979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 237979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_BUSY: 238979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_COMMAND_BUSY; 239979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 240979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_CMD_STORED: 241979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_COMMAND_STORED; 242979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 243979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_NO_RESOURCES: 244979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_NO_RESOURCES; 245979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 246979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_MODE_UNSUPPORTED: 247979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_WRONG_MODE: 248979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_MODE4_LEVEL4_NOT_SUPPORTED: 249979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_MODE_UNSUPPORTED; 250979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 251979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_ILLEGAL_VALUE: 252979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_SCO_BAD_LENGTH: 253979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_ILLEGAL_VALUE; 254979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 255979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_UNKNOWN_ADDR: 256979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_UNKNOWN_ADDR; 257979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 258979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_DEVICE_TIMEOUT: 259979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_DEVICE_TIMEOUT; 260979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 261979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_FAILED_ON_SECURITY: 262979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_REPEATED_ATTEMPTS: 263979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_NOT_AUTHORIZED: 264979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_SECURITY_ERROR; 265979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 266979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_DEV_RESET: 267979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_ILLEGAL_ACTION: 268979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_INCORRECT_STATE; 269979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 270979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_BAD_VALUE_RET: 271979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_INVALID_CONTROLLER_OUTPUT; 272979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 273979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_DELAY_CHECK: 274979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_DELAYED_ENCRYPTION_CHECK; 275979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 276979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach case BTM_ERR_PROCESSING: 277979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach default: 278979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach return BT_GATTC_ERR_PROCESSING; 279979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach } 280979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach} 281979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 2828444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbachstatic void btapp_gattc_req_data(UINT16 event, char *p_dest, char *p_src) 2838444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach{ 28452a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach tBTA_GATTC *p_dest_data = (tBTA_GATTC*) p_dest; 28552a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach tBTA_GATTC *p_src_data = (tBTA_GATTC*) p_src; 2868444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach 2878444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach if (!p_src_data || !p_dest_data) 2888444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach return; 2898444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach 2908444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach // Copy basic structure first 2913f06e14fddc0e674347ae28ea4a25218d4ce1d2aPavlin Radoslavov maybe_non_aligned_memcpy(p_dest_data, p_src_data, sizeof(*p_src_data)); 2928444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach 2938444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach // Allocate buffer for request data if necessary 2948444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach switch (event) 2958444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach { 2968444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach case BTA_GATTC_READ_CHAR_EVT: 2978444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach case BTA_GATTC_READ_DESCR_EVT: 2988444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach 299e4020c28c8a9dc56f927b03a8ca3a17d9401bc1eAndre Eisenbach if (p_src_data->read.p_value != NULL) 3008444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach { 301713993d1784ab7c23aee1fa3cf1ab8676cc0aa69Jakub Pawlowski p_dest_data->read.p_value = (tBTA_GATT_UNFMT *)osi_malloc(sizeof(tBTA_GATT_UNFMT)); 3028444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach 303717a4a9f3a044f264ec2482c2d1806ec3093707aPavlin Radoslavov memcpy(p_dest_data->read.p_value, p_src_data->read.p_value, 3049dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski sizeof(tBTA_GATT_UNFMT)); 305717a4a9f3a044f264ec2482c2d1806ec3093707aPavlin Radoslavov 306717a4a9f3a044f264ec2482c2d1806ec3093707aPavlin Radoslavov // Allocate buffer for att value if necessary 3079dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski if (p_src_data->read.p_value->len > 0 && 3089dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski p_src_data->read.p_value->p_value != NULL) { 3099dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski p_dest_data->read.p_value->p_value = 310713993d1784ab7c23aee1fa3cf1ab8676cc0aa69Jakub Pawlowski (UINT8 *)osi_malloc(p_src_data->read.p_value->len); 3119dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski memcpy(p_dest_data->read.p_value->p_value, 3129dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski p_src_data->read.p_value->p_value, 3139dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski p_src_data->read.p_value->len); 3148444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach } 315717a4a9f3a044f264ec2482c2d1806ec3093707aPavlin Radoslavov } else { 316e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_WARNING("%s :Src read.p_value ptr is NULL for event 0x%x", 317e4020c28c8a9dc56f927b03a8ca3a17d9401bc1eAndre Eisenbach __FUNCTION__, event); 318e4020c28c8a9dc56f927b03a8ca3a17d9401bc1eAndre Eisenbach p_dest_data->read.p_value = NULL; 319e4020c28c8a9dc56f927b03a8ca3a17d9401bc1eAndre Eisenbach 320e4020c28c8a9dc56f927b03a8ca3a17d9401bc1eAndre Eisenbach } 3218444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach break; 3228444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach 3238444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach default: 3248444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach break; 3258444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach } 3268444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach} 3278444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach 3288444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbachstatic void btapp_gattc_free_req_data(UINT16 event, tBTA_GATTC *p_data) 3298444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach{ 3308444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach switch (event) 3318444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach { 3328444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach case BTA_GATTC_READ_CHAR_EVT: 3338444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach case BTA_GATTC_READ_DESCR_EVT: 3348444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach if (p_data != NULL && p_data->read.p_value != NULL) 3358444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach { 3369dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski if (p_data->read.p_value->len > 0) 3379dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski osi_free_and_reset((void **)&p_data->read.p_value->p_value); 3389dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski 339cceb430489a70add1b996d54289867c17f4ac0fdPavlin Radoslavov osi_free_and_reset((void **)&p_data->read.p_value); 3408444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach } 3418444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach break; 3428444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach 3438444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach default: 3448444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach break; 3458444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach } 3468444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach} 3478444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach 348ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_gattc_init_dev_cb(void) 349ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 350ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memset(p_dev_cb, 0, sizeof(btif_gattc_dev_cb_t)); 351ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 352c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 353ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_gattc_add_remote_bdaddr (BD_ADDR p_bda, uint8_t addr_type) 354ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 355ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t i; 356ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta for (i = 0; i < BTIF_GATT_MAX_OBSERVED_DEV; i++) 357ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 358ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (!p_dev_cb->remote_dev[i].in_use ) 359ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 360ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(p_dev_cb->remote_dev[i].bd_addr.address, p_bda, BD_ADDR_LEN); 361ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_dev_cb->addr_type = addr_type; 362ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_dev_cb->remote_dev[i].in_use = TRUE; 363db554581079863974af8e1289646f5deea6fc044Marie Janssen LOG_VERBOSE(LOG_TAG, "%s device added idx=%d", __FUNCTION__, i ); 364ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 365ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 366ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 367ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 368ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if ( i == BTIF_GATT_MAX_OBSERVED_DEV) 369ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 370ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta i= p_dev_cb->next_storage_idx; 371ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(p_dev_cb->remote_dev[i].bd_addr.address, p_bda, BD_ADDR_LEN); 372ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_dev_cb->addr_type = addr_type; 373ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_dev_cb->remote_dev[i].in_use = TRUE; 374db554581079863974af8e1289646f5deea6fc044Marie Janssen LOG_VERBOSE(LOG_TAG, "%s device overwrite idx=%d", __FUNCTION__, i ); 375ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_dev_cb->next_storage_idx++; 37616fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham if (p_dev_cb->next_storage_idx >= BTIF_GATT_MAX_OBSERVED_DEV) 377ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_dev_cb->next_storage_idx = 0; 378ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 379ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 380ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 381ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic BOOLEAN btif_gattc_find_bdaddr (BD_ADDR p_bda) 382ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 383ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t i; 384ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta for (i = 0; i < BTIF_GATT_MAX_OBSERVED_DEV; i++) 385ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 386ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (p_dev_cb->remote_dev[i].in_use && 387ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta !memcmp(p_dev_cb->remote_dev[i].bd_addr.address, p_bda, BD_ADDR_LEN)) 388ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 389ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return TRUE; 390ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 391ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 392ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return FALSE; 393ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 394ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 395ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_gattc_update_properties ( btif_gattc_cb_t *p_btif_cb ) 396ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 397ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t remote_name_len; 398ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t *p_eir_remote_name=NULL; 399ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdname_t bdname; 400ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 401a50fc88c9f784a2422ceac014fea47ac1717647bZach Johnson p_eir_remote_name = BTM_CheckEirData(p_btif_cb->value, 402ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTM_EIR_COMPLETE_LOCAL_NAME_TYPE, &remote_name_len); 403ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 40416fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham if (p_eir_remote_name == NULL) 405ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 406a50fc88c9f784a2422ceac014fea47ac1717647bZach Johnson p_eir_remote_name = BTM_CheckEirData(p_btif_cb->value, 407ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_EIR_SHORTENED_LOCAL_NAME_TYPE, &remote_name_len); 408ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 409ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 41016fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham if (p_eir_remote_name) 411ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 412bcbf9cd0727f6903f9cf6c165453539fc55b6072Mike J. Chen memcpy(bdname.name, p_eir_remote_name, remote_name_len); 413bcbf9cd0727f6903f9cf6c165453539fc55b6072Mike J. Chen bdname.name[remote_name_len]='\0'; 414ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 415db554581079863974af8e1289646f5deea6fc044Marie Janssen LOG_DEBUG(LOG_TAG, "%s BLE device name=%s len=%d dev_type=%d", __FUNCTION__, bdname.name, 416ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta remote_name_len, p_btif_cb->device_type ); 417ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_dm_update_ble_remote_properties( p_btif_cb->bd_addr.address, bdname.name, 418ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_btif_cb->device_type); 419ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 420ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 421ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 422ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_gattc_upstreams_evt(uint16_t event, char* p_param) 423ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 424db554581079863974af8e1289646f5deea6fc044Marie Janssen LOG_VERBOSE(LOG_TAG, "%s: Event %d", __FUNCTION__, event); 425ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 42652a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach tBTA_GATTC *p_data = (tBTA_GATTC*) p_param; 427ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta switch (event) 428ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 429ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_REG_EVT: 430ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 431ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_uuid_t app_uuid; 432ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bta_to_btif_uuid(&app_uuid, &p_data->reg_oper.app_uuid); 433ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, client->register_client_cb 434ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , p_data->reg_oper.status 435ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , p_data->reg_oper.client_if 436ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , &app_uuid 437ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ); 438ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 439ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 440ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 441ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_DEREG_EVT: 442ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 443ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 444ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_READ_CHAR_EVT: 445ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 446ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btgatt_read_params_t data; 447ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta set_read_value(&data, &p_data->read); 448ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 449ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, client->read_characteristic_cb 450ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , p_data->read.conn_id, p_data->read.status, &data); 451ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 452ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 453ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 454ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_WRITE_CHAR_EVT: 455ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_PREP_WRITE_EVT: 456ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 4579dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski HAL_CBACK(bt_gatt_callbacks, client->write_characteristic_cb, 4589dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski p_data->write.conn_id, p_data->write.status, p_data->write.handle); 459ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 460ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 461ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 462ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_EXEC_EVT: 463ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 464ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, client->execute_write_cb 465ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , p_data->exec_cmpl.conn_id, p_data->exec_cmpl.status 466ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ); 467ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 468ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 469ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 470ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_SEARCH_CMPL_EVT: 471ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 472ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, client->search_complete_cb 473ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , p_data->search_cmpl.conn_id, p_data->search_cmpl.status); 474ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 475ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 476ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 477ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_READ_DESCR_EVT: 478ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 479ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btgatt_read_params_t data; 480ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta set_read_value(&data, &p_data->read); 481ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 482ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, client->read_descriptor_cb 483ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , p_data->read.conn_id, p_data->read.status, &data); 484ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 485ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 486ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 487ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_WRITE_DESCR_EVT: 488ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 4899dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski HAL_CBACK(bt_gatt_callbacks, client->write_descriptor_cb, 4909dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski p_data->write.conn_id, p_data->write.status, p_data->write.handle); 491ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 492ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 493ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 494ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_NOTIF_EVT: 495ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 496ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btgatt_notify_params_t data; 497ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 498ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(data.bda.address, p_data->notify.bda); 499ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(data.value, p_data->notify.value, p_data->notify.len); 500ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 5019dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski data.handle = p_data->notify.handle; 502ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta data.is_notify = p_data->notify.is_notify; 503ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta data.len = p_data->notify.len; 504ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 5059dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski HAL_CBACK(bt_gatt_callbacks, client->notify_cb, p_data->notify.conn_id, &data); 506ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 507ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (p_data->notify.is_notify == FALSE) 5089dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski BTA_GATTC_SendIndConfirm(p_data->notify.conn_id, p_data->notify.handle); 5099dc998503590163068845827d951fc2f05a17bdaJakub Pawlowski 510ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 511ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 512ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 513ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_OPEN_EVT: 514ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 515ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bda; 516ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bda.address, p_data->open.remote_bda); 517ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 518ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, client->open_cb, p_data->open.conn_id 519ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , p_data->open.status, p_data->open.client_if, &bda); 5206975b4d711142b885af479721cada448952c6b41Andre Eisenbach 5219426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach if (GATT_DEF_BLE_MTU_SIZE != p_data->open.mtu && p_data->open.mtu) 5229426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach { 5239426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach HAL_CBACK(bt_gatt_callbacks, client->configure_mtu_cb, p_data->open.conn_id 5249426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach , p_data->open.status , p_data->open.mtu); 5259426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach } 5269426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach 5276975b4d711142b885af479721cada448952c6b41Andre Eisenbach if (p_data->open.status == BTA_GATT_OK) 5284f6c9b4f68d152baf7aa029cbe9b570994584101Nitin Arora btif_gatt_check_encrypted_link(p_data->open.remote_bda, p_data->open.transport); 529ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 530ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 531ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 532ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_CLOSE_EVT: 533ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 534ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bda; 535ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bda.address, p_data->close.remote_bda); 536ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, client->close_cb, p_data->close.conn_id 537ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , p_data->status, p_data->close.client_if, &bda); 538ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 539ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 540ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 541ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_ACL_EVT: 542db554581079863974af8e1289646f5deea6fc044Marie Janssen LOG_DEBUG(LOG_TAG, "BTA_GATTC_ACL_EVT: status = %d", p_data->status); 543ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* Ignore for now */ 544ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 545ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 546ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTC_CANCEL_OPEN_EVT: 547ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 548ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 549ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATT_OBSERVE_EVT: 550ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 55152a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t*) p_param; 552aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi uint8_t remote_name_len; 553aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi uint8_t *p_eir_remote_name=NULL; 5547fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta bt_device_type_t dev_type; 5557fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta bt_property_t properties; 556aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi 557a50fc88c9f784a2422ceac014fea47ac1717647bZach Johnson p_eir_remote_name = BTM_CheckEirData(p_btif_cb->value, 558aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi BTM_EIR_COMPLETE_LOCAL_NAME_TYPE, &remote_name_len); 559aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi 56016fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham if (p_eir_remote_name == NULL) 561ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 562a50fc88c9f784a2422ceac014fea47ac1717647bZach Johnson p_eir_remote_name = BTM_CheckEirData(p_btif_cb->value, 563aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi BT_EIR_SHORTENED_LOCAL_NAME_TYPE, &remote_name_len); 564aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi } 565aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi 566aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi if ((p_btif_cb->addr_type != BLE_ADDR_RANDOM) || (p_eir_remote_name)) 567aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi { 568aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi if (!btif_gattc_find_bdaddr(p_btif_cb->bd_addr.address)) 569aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi { 570aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi btif_gattc_add_remote_bdaddr(p_btif_cb->bd_addr.address, p_btif_cb->addr_type); 571aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi btif_gattc_update_properties(p_btif_cb); 572aefcb184639ff24bf294dfa4f91bd22202d1f93eSunny Kapdi } 573ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 5747fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 575713993d1784ab7c23aee1fa3cf1ab8676cc0aa69Jakub Pawlowski dev_type = (bt_device_type_t) p_btif_cb->device_type; 5767fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta BTIF_STORAGE_FILL_PROPERTY(&properties, 5777fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta BT_PROPERTY_TYPE_OF_DEVICE, sizeof(dev_type), &dev_type); 5787fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta btif_storage_set_remote_device_property(&(p_btif_cb->bd_addr), &properties); 5797fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 5807b9fe757f5df8c529c506b1c41403f2f3f204f9eAndre Eisenbach btif_storage_set_remote_addr_type( &p_btif_cb->bd_addr, p_btif_cb->addr_type); 5817b9fe757f5df8c529c506b1c41403f2f3f204f9eAndre Eisenbach 582ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, client->scan_result_cb, 583ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta &p_btif_cb->bd_addr, p_btif_cb->rssi, p_btif_cb->value); 584ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 585ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 586ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 5875c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach case BTA_GATTC_LISTEN_EVT: 5885c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach { 5895c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach HAL_CBACK(bt_gatt_callbacks, client->listen_cb 5905c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach , p_data->reg_oper.status 5915c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach , p_data->reg_oper.client_if 5925c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach ); 5935c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach break; 5945c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach } 5959426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach 5969426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach case BTA_GATTC_CFG_MTU_EVT: 5979426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach { 5989426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach HAL_CBACK(bt_gatt_callbacks, client->configure_mtu_cb, p_data->cfg_mtu.conn_id 5999426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach , p_data->cfg_mtu.status , p_data->cfg_mtu.mtu); 6009426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach break; 6019426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach } 60217b04bd498405f2bb109a85562ebbdcb6bb06e95Andre Eisenbach 603a6ce7751d84218c193eb90d390aef23217b1737eWei Wang case BTA_GATTC_MULT_ADV_ENB_EVT: 604a6ce7751d84218c193eb90d390aef23217b1737eWei Wang { 60552a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t*) p_param; 60616fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham if (0xFF != p_btif_cb->inst_id) 60716fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham btif_multi_adv_add_instid_map(p_btif_cb->client_if, p_btif_cb->inst_id, false); 608a6ce7751d84218c193eb90d390aef23217b1737eWei Wang HAL_CBACK(bt_gatt_callbacks, client->multi_adv_enable_cb 609a6ce7751d84218c193eb90d390aef23217b1737eWei Wang , p_btif_cb->client_if 610a6ce7751d84218c193eb90d390aef23217b1737eWei Wang , p_btif_cb->status 611a6ce7751d84218c193eb90d390aef23217b1737eWei Wang ); 6129dd5a9c11f2022fa9709f0c34f04560c21105152Andre Eisenbach btif_multi_adv_timer_ctrl(p_btif_cb->client_if, 61378bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov (p_btif_cb->status == BTA_GATT_OK) ? 61478bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_multi_adv_stop_cb : NULL); 615a6ce7751d84218c193eb90d390aef23217b1737eWei Wang break; 616a6ce7751d84218c193eb90d390aef23217b1737eWei Wang } 617a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 618a6ce7751d84218c193eb90d390aef23217b1737eWei Wang case BTA_GATTC_MULT_ADV_UPD_EVT: 619a6ce7751d84218c193eb90d390aef23217b1737eWei Wang { 62052a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t*) p_param; 621a6ce7751d84218c193eb90d390aef23217b1737eWei Wang HAL_CBACK(bt_gatt_callbacks, client->multi_adv_update_cb 622a6ce7751d84218c193eb90d390aef23217b1737eWei Wang , p_btif_cb->client_if 623a6ce7751d84218c193eb90d390aef23217b1737eWei Wang , p_btif_cb->status 624a6ce7751d84218c193eb90d390aef23217b1737eWei Wang ); 6259dd5a9c11f2022fa9709f0c34f04560c21105152Andre Eisenbach btif_multi_adv_timer_ctrl(p_btif_cb->client_if, 62678bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov (p_btif_cb->status == BTA_GATT_OK) ? 62778bcff79e1b1f0efce436b33bdd6da88745bfc8aPavlin Radoslavov btif_multi_adv_stop_cb : NULL); 628a6ce7751d84218c193eb90d390aef23217b1737eWei Wang break; 629a6ce7751d84218c193eb90d390aef23217b1737eWei Wang } 630a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 631a6ce7751d84218c193eb90d390aef23217b1737eWei Wang case BTA_GATTC_MULT_ADV_DATA_EVT: 632a6ce7751d84218c193eb90d390aef23217b1737eWei Wang { 63352a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t*) p_param; 6343770c47387d3dfc6d2e2d32f4409a82119e726e3Satya Calloji btif_gattc_clear_clientif(p_btif_cb->client_if, FALSE); 635a6ce7751d84218c193eb90d390aef23217b1737eWei Wang HAL_CBACK(bt_gatt_callbacks, client->multi_adv_data_cb 636a6ce7751d84218c193eb90d390aef23217b1737eWei Wang , p_btif_cb->client_if 637a6ce7751d84218c193eb90d390aef23217b1737eWei Wang , p_btif_cb->status 638a6ce7751d84218c193eb90d390aef23217b1737eWei Wang ); 639a6ce7751d84218c193eb90d390aef23217b1737eWei Wang break; 640a6ce7751d84218c193eb90d390aef23217b1737eWei Wang } 641a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 642a6ce7751d84218c193eb90d390aef23217b1737eWei Wang case BTA_GATTC_MULT_ADV_DIS_EVT: 643a6ce7751d84218c193eb90d390aef23217b1737eWei Wang { 64452a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t*) p_param; 6453770c47387d3dfc6d2e2d32f4409a82119e726e3Satya Calloji btif_gattc_clear_clientif(p_btif_cb->client_if, TRUE); 646a6ce7751d84218c193eb90d390aef23217b1737eWei Wang HAL_CBACK(bt_gatt_callbacks, client->multi_adv_disable_cb 647a6ce7751d84218c193eb90d390aef23217b1737eWei Wang , p_btif_cb->client_if 648a6ce7751d84218c193eb90d390aef23217b1737eWei Wang , p_btif_cb->status 649a6ce7751d84218c193eb90d390aef23217b1737eWei Wang ); 650a6ce7751d84218c193eb90d390aef23217b1737eWei Wang break; 651a6ce7751d84218c193eb90d390aef23217b1737eWei Wang } 652a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 653a6ce7751d84218c193eb90d390aef23217b1737eWei Wang case BTA_GATTC_ADV_DATA_EVT: 654a6ce7751d84218c193eb90d390aef23217b1737eWei Wang { 6553770c47387d3dfc6d2e2d32f4409a82119e726e3Satya Calloji btif_gattc_cleanup_inst_cb(STD_ADV_INSTID, FALSE); 656a6ce7751d84218c193eb90d390aef23217b1737eWei Wang /* No HAL callback available */ 657a6ce7751d84218c193eb90d390aef23217b1737eWei Wang break; 658a6ce7751d84218c193eb90d390aef23217b1737eWei Wang } 659a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 66017b04bd498405f2bb109a85562ebbdcb6bb06e95Andre Eisenbach case BTA_GATTC_CONGEST_EVT: 66117b04bd498405f2bb109a85562ebbdcb6bb06e95Andre Eisenbach HAL_CBACK(bt_gatt_callbacks, client->congestion_cb 66217b04bd498405f2bb109a85562ebbdcb6bb06e95Andre Eisenbach , p_data->congest.conn_id 66317b04bd498405f2bb109a85562ebbdcb6bb06e95Andre Eisenbach , p_data->congest.congested 66417b04bd498405f2bb109a85562ebbdcb6bb06e95Andre Eisenbach ); 66517b04bd498405f2bb109a85562ebbdcb6bb06e95Andre Eisenbach break; 66617b04bd498405f2bb109a85562ebbdcb6bb06e95Andre Eisenbach 667c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji case BTA_GATTC_BTH_SCAN_CFG_EVT: 668c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 66952a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach btgatt_batch_track_cb_t *p_data = (btgatt_batch_track_cb_t*) p_param; 670c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji HAL_CBACK(bt_gatt_callbacks, client->batchscan_cfg_storage_cb 671c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji , p_data->client_if 672c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji , p_data->status 673c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji ); 674c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji break; 675c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 676c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 677c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji case BTA_GATTC_BTH_SCAN_ENB_EVT: 678c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 67952a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach btgatt_batch_track_cb_t *p_data = (btgatt_batch_track_cb_t*) p_param; 680c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji HAL_CBACK(bt_gatt_callbacks, client->batchscan_enb_disable_cb 681c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji , ENABLE_BATCH_SCAN 682c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji , p_data->client_if 683c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji , p_data->status); 684c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji break; 685c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 686c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 687c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji case BTA_GATTC_BTH_SCAN_DIS_EVT: 688c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 68952a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach btgatt_batch_track_cb_t *p_data = (btgatt_batch_track_cb_t*) p_param; 690c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji HAL_CBACK(bt_gatt_callbacks, client->batchscan_enb_disable_cb 691c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji , DISABLE_BATCH_SCAN 692c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji , p_data->client_if 693c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji , p_data->status); 694c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji break; 695c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 696c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 697c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji case BTA_GATTC_BTH_SCAN_THR_EVT: 698c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 69952a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach btgatt_batch_track_cb_t *p_data = (btgatt_batch_track_cb_t*) p_param; 700c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji HAL_CBACK(bt_gatt_callbacks, client->batchscan_threshold_cb 701c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji , p_data->client_if); 702c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji break; 703c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 704c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 705c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji case BTA_GATTC_BTH_SCAN_RD_EVT: 706c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 70752a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach btgatt_batch_track_cb_t *p_data = (btgatt_batch_track_cb_t*) p_param; 708c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji uint8_t *p_rep_data = NULL; 709c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 710adb7bb50469db992969295792a7ba3b73f9e24b3Satya Calloji if (p_data->read_reports.data_len > 0 && NULL != p_data->read_reports.p_rep_data) 711c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 712713993d1784ab7c23aee1fa3cf1ab8676cc0aa69Jakub Pawlowski p_rep_data = (uint8_t *)osi_malloc(p_data->read_reports.data_len); 713c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji memcpy(p_rep_data, p_data->read_reports.p_rep_data, p_data->read_reports.data_len); 714c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 715c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 716c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji HAL_CBACK(bt_gatt_callbacks, client->batchscan_reports_cb 717c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji , p_data->client_if, p_data->status, p_data->read_reports.report_format 718c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji , p_data->read_reports.num_records, p_data->read_reports.data_len, p_rep_data); 719cceb430489a70add1b996d54289867c17f4ac0fdPavlin Radoslavov osi_free(p_rep_data); 720c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji break; 721c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 722c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 7231acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji case BTA_GATTC_ADV_VSC_EVT: 7241acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji { 725f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji btgatt_track_adv_info_t *p_data = (btgatt_track_adv_info_t*)p_param; 726f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji btgatt_track_adv_info_t adv_info_data; 727f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji 728f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji memset(&adv_info_data, 0, sizeof(btgatt_track_adv_info_t)); 729f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji 730f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji btif_gatt_move_track_adv_data(&adv_info_data, p_data); 731f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji HAL_CBACK(bt_gatt_callbacks, client->track_adv_event_cb, &adv_info_data); 7321acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji break; 7331acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji } 7341acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji 735ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta default: 736db554581079863974af8e1289646f5deea6fc044Marie Janssen LOG_ERROR(LOG_TAG, "%s: Unhandled event (%d)!", __FUNCTION__, event); 737ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 738ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 7398444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach 7408444d1e649864c28b0c124bc2d16f7c153f01f14Andre Eisenbach btapp_gattc_free_req_data(event, p_data); 741ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 742ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 7436975b4d711142b885af479721cada448952c6b41Andre Eisenbachstatic void bta_gattc_cback(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) 744ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 745ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_status_t status = btif_transfer_context(btif_gattc_upstreams_evt, 746713993d1784ab7c23aee1fa3cf1ab8676cc0aa69Jakub Pawlowski (uint16_t) event, (char*) p_data, sizeof(tBTA_GATTC), btapp_gattc_req_data); 747ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ASSERTC(status == BT_STATUS_SUCCESS, "Context transfer failed!", status); 748ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 749ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 750a6ce7751d84218c193eb90d390aef23217b1737eWei Wangstatic void bta_gattc_multi_adv_cback(tBTA_BLE_MULTI_ADV_EVT event, UINT8 inst_id, 751a6ce7751d84218c193eb90d390aef23217b1737eWei Wang void *p_ref, tBTA_STATUS call_status) 752a6ce7751d84218c193eb90d390aef23217b1737eWei Wang{ 753a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_gattc_cb_t btif_cb; 754a6ce7751d84218c193eb90d390aef23217b1737eWei Wang tBTA_GATTC_EVT upevt; 755a6ce7751d84218c193eb90d390aef23217b1737eWei Wang uint8_t client_if = 0; 756a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 75716fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham if (NULL == p_ref) 758a6ce7751d84218c193eb90d390aef23217b1737eWei Wang { 75916fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham BTIF_TRACE_WARNING("%s Invalid p_ref received",__FUNCTION__); 76016fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham } 76116fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham else 76216fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham { 76316fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham client_if = *(UINT8 *) p_ref; 764a6ce7751d84218c193eb90d390aef23217b1737eWei Wang } 765a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 766e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s -Inst ID %d, Status:%x, client_if:%d",__FUNCTION__,inst_id, call_status, 767a6ce7751d84218c193eb90d390aef23217b1737eWei Wang client_if); 768a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_cb.status = call_status; 769a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_cb.client_if = client_if; 770a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_cb.inst_id = inst_id; 771a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 772a6ce7751d84218c193eb90d390aef23217b1737eWei Wang switch(event) 773a6ce7751d84218c193eb90d390aef23217b1737eWei Wang { 774a6ce7751d84218c193eb90d390aef23217b1737eWei Wang case BTA_BLE_MULTI_ADV_ENB_EVT: 775a6ce7751d84218c193eb90d390aef23217b1737eWei Wang upevt = BTA_GATTC_MULT_ADV_ENB_EVT; 776a6ce7751d84218c193eb90d390aef23217b1737eWei Wang break; 777a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 778a6ce7751d84218c193eb90d390aef23217b1737eWei Wang case BTA_BLE_MULTI_ADV_DISABLE_EVT: 779a6ce7751d84218c193eb90d390aef23217b1737eWei Wang upevt = BTA_GATTC_MULT_ADV_DIS_EVT; 780a6ce7751d84218c193eb90d390aef23217b1737eWei Wang break; 781a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 782a6ce7751d84218c193eb90d390aef23217b1737eWei Wang case BTA_BLE_MULTI_ADV_PARAM_EVT: 783a6ce7751d84218c193eb90d390aef23217b1737eWei Wang upevt = BTA_GATTC_MULT_ADV_UPD_EVT; 784a6ce7751d84218c193eb90d390aef23217b1737eWei Wang break; 785a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 786a6ce7751d84218c193eb90d390aef23217b1737eWei Wang case BTA_BLE_MULTI_ADV_DATA_EVT: 787a6ce7751d84218c193eb90d390aef23217b1737eWei Wang upevt = BTA_GATTC_MULT_ADV_DATA_EVT; 788a6ce7751d84218c193eb90d390aef23217b1737eWei Wang break; 789a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 790a6ce7751d84218c193eb90d390aef23217b1737eWei Wang default: 791a6ce7751d84218c193eb90d390aef23217b1737eWei Wang return; 792a6ce7751d84218c193eb90d390aef23217b1737eWei Wang } 793a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 794a6ce7751d84218c193eb90d390aef23217b1737eWei Wang bt_status_t status = btif_transfer_context(btif_gattc_upstreams_evt, (uint16_t) upevt, 795a6ce7751d84218c193eb90d390aef23217b1737eWei Wang (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL); 796a6ce7751d84218c193eb90d390aef23217b1737eWei Wang ASSERTC(status == BT_STATUS_SUCCESS, "Context transfer failed!", status); 797a6ce7751d84218c193eb90d390aef23217b1737eWei Wang} 798a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 799a6ce7751d84218c193eb90d390aef23217b1737eWei Wangstatic void bta_gattc_set_adv_data_cback(tBTA_STATUS call_status) 800a6ce7751d84218c193eb90d390aef23217b1737eWei Wang{ 801a6ce7751d84218c193eb90d390aef23217b1737eWei Wang UNUSED(call_status); 802a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_gattc_cb_t btif_cb; 803a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_cb.status = call_status; 804a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_cb.action = 0; 805a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_transfer_context(btif_gattc_upstreams_evt, BTA_GATTC_ADV_DATA_EVT, 806a6ce7751d84218c193eb90d390aef23217b1737eWei Wang (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL); 807a6ce7751d84218c193eb90d390aef23217b1737eWei Wang} 808a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 809c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Callojistatic void bta_batch_scan_setup_cb (tBTA_BLE_BATCH_SCAN_EVT evt, 810c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji tBTA_DM_BLE_REF_VALUE ref_value, tBTA_STATUS status) 811c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji{ 812c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji UINT8 upevt = 0; 813c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btgatt_batch_track_cb_t btif_scan_track_cb; 814c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 815c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_scan_track_cb.status = status; 816c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_scan_track_cb.client_if = ref_value; 8171a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji BTIF_TRACE_DEBUG("bta_batch_scan_setup_cb-Status:%x, client_if:%d, evt=%d", 818c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji status, ref_value, evt); 819c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 820c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji switch(evt) 821c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 822c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji case BTA_BLE_BATCH_SCAN_ENB_EVT: 823c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 824c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji upevt = BTA_GATTC_BTH_SCAN_ENB_EVT; 825c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji break; 826c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 827c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 828c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji case BTA_BLE_BATCH_SCAN_DIS_EVT: 829c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 830c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji upevt = BTA_GATTC_BTH_SCAN_DIS_EVT; 831c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji break; 832c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 833c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 834c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji case BTA_BLE_BATCH_SCAN_CFG_STRG_EVT: 835c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 836c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji upevt = BTA_GATTC_BTH_SCAN_CFG_EVT; 837c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji break; 838c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 839c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 840c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji case BTA_BLE_BATCH_SCAN_DATA_EVT: 841c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 842c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji upevt = BTA_GATTC_BTH_SCAN_RD_EVT; 843c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji break; 844c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 845c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 846c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji case BTA_BLE_BATCH_SCAN_THRES_EVT: 847c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 848c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji upevt = BTA_GATTC_BTH_SCAN_THR_EVT; 849c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji break; 850c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 851c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 852c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji default: 853c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji return; 854c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 855c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 856c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_transfer_context(btif_gattc_upstreams_evt, upevt,(char*) &btif_scan_track_cb, 857c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji sizeof(btgatt_batch_track_cb_t), NULL); 858c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 859c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji} 860c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 861c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Callojistatic void bta_batch_scan_threshold_cb(tBTA_DM_BLE_REF_VALUE ref_value) 862c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji{ 863c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btgatt_batch_track_cb_t btif_scan_track_cb; 864c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_scan_track_cb.status = 0; 865c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_scan_track_cb.client_if = ref_value; 866c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 8671a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji BTIF_TRACE_DEBUG("%s - client_if:%d",__FUNCTION__, ref_value); 868c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 869c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_transfer_context(btif_gattc_upstreams_evt, BTA_GATTC_BTH_SCAN_THR_EVT, 870c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji (char*) &btif_scan_track_cb, sizeof(btif_gattc_cb_t), NULL); 871c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji} 872c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 873c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Callojistatic void bta_batch_scan_reports_cb(tBTA_DM_BLE_REF_VALUE ref_value, UINT8 report_format, 874c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji UINT8 num_records, UINT16 data_len, 875c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji UINT8* p_rep_data, tBTA_STATUS status) 876c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji{ 877c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btgatt_batch_track_cb_t btif_scan_track_cb; 878adb7bb50469db992969295792a7ba3b73f9e24b3Satya Calloji memset(&btif_scan_track_cb, 0, sizeof(btgatt_batch_track_cb_t)); 8791a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji BTIF_TRACE_DEBUG("%s - client_if:%d, %d, %d, %d",__FUNCTION__, ref_value, status, num_records, 880c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji data_len); 881c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 882c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_scan_track_cb.status = status; 883c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 884c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_scan_track_cb.client_if = ref_value; 885c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_scan_track_cb.read_reports.report_format = report_format; 886c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_scan_track_cb.read_reports.data_len = data_len; 887c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_scan_track_cb.read_reports.num_records = num_records; 888c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 88916fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham if (data_len > 0) 890c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji { 891713993d1784ab7c23aee1fa3cf1ab8676cc0aa69Jakub Pawlowski btif_scan_track_cb.read_reports.p_rep_data = (UINT8 *)osi_malloc(data_len); 892c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji memcpy(btif_scan_track_cb.read_reports.p_rep_data, p_rep_data, data_len); 893cceb430489a70add1b996d54289867c17f4ac0fdPavlin Radoslavov osi_free(p_rep_data); 894c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji } 895c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 896c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_transfer_context(btif_gattc_upstreams_evt, BTA_GATTC_BTH_SCAN_RD_EVT, 897c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji (char*) &btif_scan_track_cb, sizeof(btgatt_batch_track_cb_t), NULL); 898c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 89916fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30Prerepa Viswanadham if (data_len > 0) 900cceb430489a70add1b996d54289867c17f4ac0fdPavlin Radoslavov osi_free_and_reset((void **)&btif_scan_track_cb.read_reports.p_rep_data); 901c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji} 902c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 9036975b4d711142b885af479721cada448952c6b41Andre Eisenbachstatic void bta_scan_results_cb (tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data) 904ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 905ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_cb_t btif_cb; 906ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t len; 907ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 908ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta switch (event) 909ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 910ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_DM_INQ_RES_EVT: 911ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 912ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(btif_cb.bd_addr.address, p_data->inq_res.bd_addr); 913ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.device_type = p_data->inq_res.device_type; 914ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.rssi = p_data->inq_res.rssi; 915ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.addr_type = p_data->inq_res.ble_addr_type; 9167fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta btif_cb.flag = p_data->inq_res.flag; 917ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (p_data->inq_res.p_eir) 918ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 919ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(btif_cb.value, p_data->inq_res.p_eir, 62); 920a50fc88c9f784a2422ceac014fea47ac1717647bZach Johnson if (BTM_CheckEirData(p_data->inq_res.p_eir, BTM_EIR_COMPLETE_LOCAL_NAME_TYPE, 921ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta &len)) 922ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 923ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->inq_res.remt_name_not_required = TRUE; 924ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 925ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 926ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 927ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 928ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 929ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_DM_INQ_CMPL_EVT: 930ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 931e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_DEBUG("%s BLE observe complete. Num Resp %d", 932ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta __FUNCTION__,p_data->inq_cmpl.num_resps); 933ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return; 934ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 935ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 936ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta default: 937e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati BTIF_TRACE_WARNING("%s : Unknown event 0x%x", __FUNCTION__, event); 938ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return; 939ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 940ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_transfer_context(btif_gattc_upstreams_evt, BTIF_GATT_OBSERVE_EVT, 941ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL); 942ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 943ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 944f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Callojistatic void bta_track_adv_event_cb(tBTA_DM_BLE_TRACK_ADV_DATA *p_track_adv_data) 9451acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji{ 946f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji btgatt_track_adv_info_t btif_scan_track_cb; 947f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji BTIF_TRACE_DEBUG("%s",__FUNCTION__); 948f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji btif_gatt_move_track_adv_data(&btif_scan_track_cb, 949f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji (btgatt_track_adv_info_t*)p_track_adv_data); 950f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji 9511acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji btif_transfer_context(btif_gattc_upstreams_evt, BTA_GATTC_ADV_VSC_EVT, 952f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56Satya Calloji (char*) &btif_scan_track_cb, sizeof(btgatt_track_adv_info_t), NULL); 9531acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji} 9541acb61ce065053f91a0f8d43e8328c9eeec4b5edSatya Calloji 955c171ac407cfc6d30a11af6b12ead39688eb897f7Jakub Pawlowskistatic void btm_read_rssi_cb(tBTM_RSSI_RESULTS *p_result) { 956c171ac407cfc6d30a11af6b12ead39688eb897f7Jakub Pawlowski bt_bdaddr_t *addr = new bt_bdaddr_t; 957c171ac407cfc6d30a11af6b12ead39688eb897f7Jakub Pawlowski bdcpy(addr->address, p_result->rem_bda); 958c171ac407cfc6d30a11af6b12ead39688eb897f7Jakub Pawlowski CLI_CBACK_IN_JNI(read_remote_rssi_cb, rssi_request_client_if, 959c171ac407cfc6d30a11af6b12ead39688eb897f7Jakub Pawlowski base::Owned(addr), p_result->rssi, p_result->status); 960ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 961ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 962da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowskistatic void bta_scan_param_setup_cb(tGATT_IF client_if, tBTM_STATUS status) { 963da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski CLI_CBACK_IN_JNI(scan_parameter_setup_completed_cb, client_if, 964da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski btif_gattc_translate_btm_status(status)); 965979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach} 966979e3421c8111a56ebfcf176f6383df58eed52eaAndre Eisenbach 967da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowskistatic void bta_scan_filt_cfg_cb(tBTA_DM_BLE_PF_ACTION action, 968da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski tBTA_DM_BLE_SCAN_COND_OP cfg_op, 969da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski tBTA_DM_BLE_PF_AVBL_SPACE avbl_space, 970da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski tBTA_STATUS status, 971da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski tBTA_DM_BLE_REF_VALUE ref_value) { 972da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski CLI_CBACK_IN_JNI(scan_filter_cfg_cb, action, ref_value, status, cfg_op, 973da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski avbl_space); 9741a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji} 9751a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji 9761a9247a1229aa65b3d1dce16426177bc5828e54dSatya Callojistatic void bta_scan_filt_param_setup_cb(UINT8 action_type, 977da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski tBTA_DM_BLE_PF_AVBL_SPACE avbl_space, 978da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski tBTA_DM_BLE_REF_VALUE ref_value, 979da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski tBTA_STATUS status) { 980da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski CLI_CBACK_IN_JNI(scan_filter_param_cb, action_type, ref_value, status, 981da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski avbl_space); 9821a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji} 9831a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji 9841a9247a1229aa65b3d1dce16426177bc5828e54dSatya Callojistatic void bta_scan_filt_status_cb(UINT8 action, tBTA_STATUS status, 985da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski tBTA_DM_BLE_REF_VALUE ref_value) { 986da5b59b5bf9cb34574c16ba784c1484055fcb1e3Jakub Pawlowski CLI_CBACK_IN_JNI(scan_filter_status_cb, action, ref_value, status); 987b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach} 988ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 989ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/******************************************************************************* 990ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Client API Functions 991ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta********************************************************************************/ 992ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 993c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowskistatic void btif_gattc_register_app_impl(tBT_UUID uuid) { 994c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski btif_gattc_incr_app_count(); 995c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski BTA_GATTC_AppRegister(&uuid, bta_gattc_cback); 996ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 997ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 998c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowskistatic bt_status_t btif_gattc_register_app(bt_uuid_t *uuid) { 999c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski CHECK_BTGATT_INIT(); 1000c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski 1001c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski tBT_UUID bt_uuid; 1002c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski btif_to_bta_uuid(&bt_uuid, uuid); 1003c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski return do_in_jni_thread(Bind(&btif_gattc_register_app_impl, bt_uuid)); 1004c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski} 1005c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski 1006c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowskistatic void btif_gattc_unregister_app_impl(int client_if) { 1007c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski btif_gattc_clear_clientif(client_if, TRUE); 1008c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski btif_gattc_decr_app_count(); 1009c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski BTA_GATTC_AppDeregister(client_if); 1010c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski} 1011c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski 1012c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowskistatic bt_status_t btif_gattc_unregister_app(int client_if) { 1013c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski CHECK_BTGATT_INIT(); 1014c8b5185a5d4c4c9c15f3ec5df4acd37c1d46f1f1Jakub Pawlowski return do_in_jni_thread(Bind(&btif_gattc_unregister_app_impl, client_if)); 1015ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1016ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1017955ff4e88ef7391632e19d1b0234cae40b6f42c1Jakub Pawlowskistatic bt_status_t btif_gattc_scan(bool start) { 1018955ff4e88ef7391632e19d1b0234cae40b6f42c1Jakub Pawlowski CHECK_BTGATT_INIT(); 1019955ff4e88ef7391632e19d1b0234cae40b6f42c1Jakub Pawlowski if (start) { 1020955ff4e88ef7391632e19d1b0234cae40b6f42c1Jakub Pawlowski btif_gattc_init_dev_cb(); 1021955ff4e88ef7391632e19d1b0234cae40b6f42c1Jakub Pawlowski return do_in_jni_thread(Bind(&BTA_DmBleObserve, TRUE, 0, 1022955ff4e88ef7391632e19d1b0234cae40b6f42c1Jakub Pawlowski (tBTA_DM_SEARCH_CBACK *)bta_scan_results_cb)); 1023955ff4e88ef7391632e19d1b0234cae40b6f42c1Jakub Pawlowski } else { 1024955ff4e88ef7391632e19d1b0234cae40b6f42c1Jakub Pawlowski return do_in_jni_thread(Bind(&BTA_DmBleObserve, FALSE, 0, nullptr)); 1025955ff4e88ef7391632e19d1b0234cae40b6f42c1Jakub Pawlowski } 1026ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1027ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 102826e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowskistatic void btif_gattc_open_impl(int client_if, BD_ADDR address, 102926e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski bool is_direct, int transport_p) { 103026e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski // Ensure device is in inquiry database 103126e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski int addr_type = 0; 103226e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski int device_type = 0; 103326e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski tBTA_GATT_TRANSPORT transport = (tBTA_GATT_TRANSPORT)BTA_GATT_TRANSPORT_LE; 103426e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski 103526e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski if (btif_get_address_type(address, &addr_type) && 103626e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski btif_get_device_type(address, &device_type) && 103726e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski device_type != BT_DEVICE_TYPE_BREDR) { 103826e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski BTA_DmAddBleDevice(address, addr_type, device_type); 103926e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski } 104026e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski 104126e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski // Check for background connections 104226e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski if (!is_direct) { 104326e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski // Check for privacy 1.0 and 1.1 controller and do not start background 104426e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski // connection if RPA offloading is not supported, since it will not 104526e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski // connect after change of random address 104626e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski if (!controller_get_interface()->supports_ble_privacy() && 104726e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski (addr_type == BLE_ADDR_RANDOM) && 104826e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski BTM_BLE_IS_RESOLVE_BDA(address)) { 104926e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski tBTM_BLE_VSC_CB vnd_capabilities; 105026e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski BTM_BleGetVendorCapabilities(&vnd_capabilities); 105126e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski if (!vnd_capabilities.rpa_offloading) { 105226e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski HAL_CBACK(bt_gatt_callbacks, client->open_cb, 0, BT_STATUS_UNSUPPORTED, 105326e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski client_if, (bt_bdaddr_t*) &address); 105426e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski return; 105526e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski } 105626e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski } 105726e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL); 105826e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski } 105926e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski 106026e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski // Determine transport 106126e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski if (transport_p != GATT_TRANSPORT_AUTO) { 106226e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski transport = transport_p; 106326e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski } else { 106426e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski switch (device_type) { 106526e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski case BT_DEVICE_TYPE_BREDR: 106626e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski transport = BTA_GATT_TRANSPORT_BR_EDR; 106726e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski break; 106826e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski 106926e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski case BT_DEVICE_TYPE_BLE: 107026e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski transport = BTA_GATT_TRANSPORT_LE; 107126e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski break; 107226e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski 107326e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski case BT_DEVICE_TYPE_DUMO: 107426e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski if (transport == GATT_TRANSPORT_LE) 107526e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski transport = BTA_GATT_TRANSPORT_LE; 107626e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski else 107726e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski transport = BTA_GATT_TRANSPORT_BR_EDR; 107826e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski break; 107926e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski } 108026e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski } 108126e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski 108226e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski // Connect! 108326e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski BTIF_TRACE_DEBUG("%s Transport=%d, device type=%d", __func__, transport, 108426e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski device_type); 108526e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski BTA_GATTC_Open(client_if, address, is_direct, transport); 108626e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski} 108726e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski 10887fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Battastatic bt_status_t btif_gattc_open(int client_if, const bt_bdaddr_t *bd_addr, 108926e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski bool is_direct, int transport) { 109026e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski CHECK_BTGATT_INIT(); 109126e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski // Closure will own this value and free it. 109226e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski uint8_t *address = new BD_ADDR; 109326e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski bdcpy(address, bd_addr->address); 109426e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski return do_in_jni_thread( 109526e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski Bind(&btif_gattc_open_impl, client_if, base::Owned(address), is_direct, 109626e51cb18509e7e04755b4fa4250c60f105ab9d2Jakub Pawlowski transport)); 1097ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1098ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1099b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowskistatic void btif_gattc_close_impl(int client_if, BD_ADDR address, 1100b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski int conn_id) { 1101b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski // Disconnect established connections 1102b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski if (conn_id != 0) 1103b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski BTA_GATTC_Close(conn_id); 1104b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski else 1105b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski BTA_GATTC_CancelOpen(client_if, address, TRUE); 1106b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski 1107b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski // Cancel pending background connections (remove from whitelist) 1108b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski BTA_GATTC_CancelOpen(client_if, address, FALSE); 1109b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski} 1110b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski 1111b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowskistatic bt_status_t btif_gattc_close(int client_if, const bt_bdaddr_t *bd_addr, 1112b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski int conn_id) { 1113b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski CHECK_BTGATT_INIT(); 1114b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski // Closure will own this value and free it. 1115b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski uint8_t *address = new BD_ADDR; 1116b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski bdcpy(address, bd_addr->address); 1117b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski return do_in_jni_thread( 1118b454953bb6620cbafba86351b91d58b47dda107dJakub Pawlowski Bind(&btif_gattc_close_impl, client_if, base::Owned(address), conn_id)); 1119ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1120ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1121144998f68990205ba711e701be6be8325dd6e820Jakub Pawlowskistatic bt_status_t btif_gattc_listen(int client_if, bool start) { 1122144998f68990205ba711e701be6be8325dd6e820Jakub Pawlowski CHECK_BTGATT_INIT(); 1123144998f68990205ba711e701be6be8325dd6e820Jakub Pawlowski#if (defined(BLE_PERIPHERAL_MODE_SUPPORT) && \ 1124144998f68990205ba711e701be6be8325dd6e820Jakub Pawlowski (BLE_PERIPHERAL_MODE_SUPPORT == TRUE)) 1125144998f68990205ba711e701be6be8325dd6e820Jakub Pawlowski return do_in_jni_thread(Bind(&BTA_GATTC_Listen, client_if, start, nullptr)); 1126144998f68990205ba711e701be6be8325dd6e820Jakub Pawlowski#else 1127144998f68990205ba711e701be6be8325dd6e820Jakub Pawlowski return do_in_jni_thread(Bind(&BTA_GATTC_Broadcast, client_if, start)); 1128144998f68990205ba711e701be6be8325dd6e820Jakub Pawlowski#endif 11295c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach} 11305c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach 11311ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowskistatic void btif_gattc_set_adv_data_impl(btif_adv_data_t *p_adv_data) { 11321ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski const int cbindex = CLNT_IF_IDX; 11331ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski if (cbindex >= 0 && btif_gattc_copy_datacb(cbindex, p_adv_data, false)) { 11341ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski btgatt_multi_adv_common_data *p_multi_adv_data_cb = 11351ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski btif_obtain_multi_adv_data_cb(); 11361ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski if (!p_adv_data->set_scan_rsp) { 11371ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski BTA_DmBleSetAdvConfig(p_multi_adv_data_cb->inst_cb[cbindex].mask, 11381ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski &p_multi_adv_data_cb->inst_cb[cbindex].data, 11391ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski bta_gattc_set_adv_data_cback); 11401ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski } else { 11411ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski BTA_DmBleSetScanRsp(p_multi_adv_data_cb->inst_cb[cbindex].mask, 11421ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski &p_multi_adv_data_cb->inst_cb[cbindex].data, 11431ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski bta_gattc_set_adv_data_cback); 11441ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski } 11451ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski } else { 11461ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski BTIF_TRACE_ERROR("%s: failed to get instance data cbindex: %d", __func__, 11471ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski cbindex); 11481ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski } 11491ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski} 11501ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski 11511ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowskistatic bt_status_t btif_gattc_set_adv_data( 11521ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski int client_if, bool set_scan_rsp, bool include_name, bool include_txpower, 11531ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski int min_interval, int max_interval, int appearance, 11541ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski uint16_t manufacturer_len, char *manufacturer_data, 11551ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski uint16_t service_data_len, char *service_data, uint16_t service_uuid_len, 11561ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski char *service_uuid) { 11571ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski CHECK_BTGATT_INIT(); 11581ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski 11591ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski btif_adv_data_t *adv_data = new btif_adv_data_t; 1160eeeac99328c23304ab24698331b6600f3b545700Andre Eisenbach 11611ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski btif_gattc_adv_data_packager( 11621ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski client_if, set_scan_rsp, include_name, include_txpower, min_interval, 11631ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski max_interval, appearance, manufacturer_len, manufacturer_data, 11641ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski service_data_len, service_data, service_uuid_len, service_uuid, adv_data); 1165eeeac99328c23304ab24698331b6600f3b545700Andre Eisenbach 11661ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski return do_in_jni_thread( 11671ce0819a83f47f3bec3c16c46befd1e7faddf0ffJakub Pawlowski Bind(&btif_gattc_set_adv_data_impl, base::Owned(adv_data))); 11685c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach} 11695c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach 1170140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowskistatic bt_status_t btif_gattc_refresh(int client_if, 1171140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowski const bt_bdaddr_t *bd_addr) { 1172140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowski CHECK_BTGATT_INIT(); 1173140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowski // Closure will own this value and free it. 1174140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowski uint8_t *address = new BD_ADDR; 1175140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowski bdcpy(address, bd_addr->address); 1176140645f6b8d87464c08f082bd14740eecab23f71Jakub Pawlowski return do_in_jni_thread(Bind(&BTA_GATTC_Refresh, base::Owned(address))); 1177ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1178ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1179d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowskistatic bt_status_t btif_gattc_search_service(int conn_id, 1180d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski bt_uuid_t *filter_uuid) { 1181d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski CHECK_BTGATT_INIT(); 1182d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski 1183d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski if (filter_uuid) { 1184d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski tBT_UUID *uuid = new tBT_UUID; 1185d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski btif_to_bta_uuid(uuid, filter_uuid); 1186d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski return do_in_jni_thread( 1187d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski Bind(&BTA_GATTC_ServiceSearchRequest, conn_id, base::Owned(uuid))); 1188d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski } else { 1189d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski return do_in_jni_thread( 1190d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski Bind(&BTA_GATTC_ServiceSearchRequest, conn_id, nullptr)); 1191d05e50e7df462c928041bf565821d77fb493bc28Jakub Pawlowski } 1192ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1193ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 119461a98132c39d3181a0ea23988ac36fbfef8194b4Jakub Pawlowskivoid btif_gattc_get_gatt_db_impl(int conn_id) { 119561a98132c39d3181a0ea23988ac36fbfef8194b4Jakub Pawlowski btgatt_db_element_t *db = NULL; 119661a98132c39d3181a0ea23988ac36fbfef8194b4Jakub Pawlowski int count = 0; 119761a98132c39d3181a0ea23988ac36fbfef8194b4Jakub Pawlowski BTA_GATTC_GetGattDb(conn_id, 0x0000, 0xFFFF, &db, &count); 1198533fdbf46fb623aefbe4d0107b5cccd41aec097aJakub Pawlowski 119961a98132c39d3181a0ea23988ac36fbfef8194b4Jakub Pawlowski HAL_CBACK(bt_gatt_callbacks, client->get_gatt_db_cb, conn_id, db, count); 120061a98132c39d3181a0ea23988ac36fbfef8194b4Jakub Pawlowski osi_free(db); 120161a98132c39d3181a0ea23988ac36fbfef8194b4Jakub Pawlowski} 120261a98132c39d3181a0ea23988ac36fbfef8194b4Jakub Pawlowski 120361a98132c39d3181a0ea23988ac36fbfef8194b4Jakub Pawlowskistatic bt_status_t btif_gattc_get_gatt_db(int conn_id) { 120461a98132c39d3181a0ea23988ac36fbfef8194b4Jakub Pawlowski CHECK_BTGATT_INIT(); 120561a98132c39d3181a0ea23988ac36fbfef8194b4Jakub Pawlowski return do_in_jni_thread(Bind(&btif_gattc_get_gatt_db_impl, conn_id)); 1206533fdbf46fb623aefbe4d0107b5cccd41aec097aJakub Pawlowski} 1207533fdbf46fb623aefbe4d0107b5cccd41aec097aJakub Pawlowski 120861a112e488a7686e5cc9680434c42895ef9db878Jakub Pawlowskistatic bt_status_t btif_gattc_read_char(int conn_id, uint16_t handle, 120961a112e488a7686e5cc9680434c42895ef9db878Jakub Pawlowski int auth_req) { 121061a112e488a7686e5cc9680434c42895ef9db878Jakub Pawlowski CHECK_BTGATT_INIT(); 121161a112e488a7686e5cc9680434c42895ef9db878Jakub Pawlowski return do_in_jni_thread( 121261a112e488a7686e5cc9680434c42895ef9db878Jakub Pawlowski Bind(&BTA_GATTC_ReadCharacteristic, conn_id, handle, auth_req)); 1213ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1214ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 121561a112e488a7686e5cc9680434c42895ef9db878Jakub Pawlowskistatic bt_status_t btif_gattc_read_char_descr(int conn_id, uint16_t handle, 121661a112e488a7686e5cc9680434c42895ef9db878Jakub Pawlowski int auth_req) { 121761a112e488a7686e5cc9680434c42895ef9db878Jakub Pawlowski CHECK_BTGATT_INIT(); 121861a112e488a7686e5cc9680434c42895ef9db878Jakub Pawlowski return do_in_jni_thread( 121961a112e488a7686e5cc9680434c42895ef9db878Jakub Pawlowski Bind(&BTA_GATTC_ReadCharDescr, conn_id, handle, auth_req)); 1220ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1221ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 122239a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowskistatic bt_status_t btif_gattc_write_char(int conn_id, uint16_t handle, 122339a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski int write_type, int len, int auth_req, 122439a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski char *p_value) { 122539a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski CHECK_BTGATT_INIT(); 122639a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski 122739a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski len = len > BTGATT_MAX_ATTR_LEN ? BTGATT_MAX_ATTR_LEN : len; 122839a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski // callback will own this value and free it. 122939a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski UINT8 *value = new UINT8(len); 123039a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski memcpy(value, p_value, len); 123139a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski 123239a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski return do_in_jni_thread(Bind(&BTA_GATTC_WriteCharValue, conn_id, handle, 123339a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski write_type, len, base::Owned(value), auth_req)); 1234ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1235ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 12369dc998503590163068845827d951fc2f05a17bdaJakub Pawlowskistatic bt_status_t btif_gattc_write_char_descr(int conn_id, uint16_t handle, 123739a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski int write_type, int len, 123839a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski int auth_req, char *p_value) { 123939a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski len = len > BTGATT_MAX_ATTR_LEN ? BTGATT_MAX_ATTR_LEN : len; 124039a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski 124139a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski // callback will own this value and free it 124239a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski // TODO(jpawlowski): This one is little hacky because of unfmt type, 124339a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski // make it accept len an val like BTA_GATTC_WriteCharValue 124439a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski tBTA_GATT_UNFMT *value = (tBTA_GATT_UNFMT *)new UINT8(sizeof(UINT16) + len); 124539a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski value->len = len; 124639a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski value->p_value = ((UINT8 *)value) + 2; 124739a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski memcpy(value->p_value, p_value, len); 124839a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski 124939a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski return do_in_jni_thread(Bind(&BTA_GATTC_WriteCharDescr, conn_id, handle, 125039a33612889a562da5c919f14df24707ba3e6007Jakub Pawlowski write_type, Owned(value), auth_req)); 1251ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1252ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1253a684a52231bf0422d991fb16e4dcfc88e4584680Jakub Pawlowskistatic bt_status_t btif_gattc_execute_write(int conn_id, int execute) { 1254a684a52231bf0422d991fb16e4dcfc88e4584680Jakub Pawlowski CHECK_BTGATT_INIT(); 1255a684a52231bf0422d991fb16e4dcfc88e4584680Jakub Pawlowski return do_in_jni_thread( 1256a684a52231bf0422d991fb16e4dcfc88e4584680Jakub Pawlowski Bind(&BTA_GATTC_ExecuteWrite, conn_id, (uint8_t)execute)); 1257ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1258ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1259ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowskistatic void btif_gattc_reg_for_notification_impl(tBTA_GATTC_IF client_if, 1260ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski const BD_ADDR bda, UINT16 handle) { 1261ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski tBTA_GATT_STATUS status = BTA_GATTC_RegisterForNotifications( 1262ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski client_if, const_cast<UINT8 *>(bda), handle); 1263ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski 1264ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski //TODO(jpawlowski): conn_id is currently unused 1265ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski HAL_CBACK(bt_gatt_callbacks, client->register_for_notification_cb, 1266ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski /* conn_id */ 0, 1, status, handle); 1267ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1268ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1269ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowskistatic bt_status_t btif_gattc_reg_for_notification(int client_if, 1270ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski const bt_bdaddr_t *bd_addr, 1271ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski uint16_t handle) { 1272ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski CHECK_BTGATT_INIT(); 1273ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski 1274ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski uint8_t *address = new BD_ADDR; 1275ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski bdcpy(address, bd_addr->address); 1276ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski return do_in_jni_thread( 1277ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski Bind(base::IgnoreResult(&btif_gattc_reg_for_notification_impl), client_if, 1278ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski base::Owned(address), handle)); 1279ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski} 1280ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski 1281ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowskistatic void btif_gattc_dereg_for_notification_impl(tBTA_GATTC_IF client_if, 1282ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski const BD_ADDR bda, UINT16 handle) { 1283ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski tBTA_GATT_STATUS status = BTA_GATTC_DeregisterForNotifications( 1284ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski client_if, const_cast<UINT8 *>(bda), handle); 1285ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski 1286ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski //TODO(jpawlowski): conn_id is currently unused 1287ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski HAL_CBACK(bt_gatt_callbacks, client->register_for_notification_cb, 1288ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski /* conn_id */ 0, 0, status, handle); 1289ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski} 1290ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski 1291ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowskistatic bt_status_t btif_gattc_dereg_for_notification(int client_if, 1292ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski const bt_bdaddr_t *bd_addr, 1293ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski uint16_t handle) { 1294ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski CHECK_BTGATT_INIT(); 1295ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski 1296ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski uint8_t *address = new BD_ADDR; 1297ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski bdcpy(address, bd_addr->address); 1298ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski return do_in_jni_thread( 1299ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski Bind(base::IgnoreResult(&btif_gattc_dereg_for_notification_impl), 1300ca9d889000b087ddb9bedaa716176be986be158fJakub Pawlowski client_if, base::Owned(address), handle)); 1301ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1302ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1303c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowskistatic bt_status_t btif_gattc_read_remote_rssi(int client_if, 1304c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski const bt_bdaddr_t *bd_addr) { 1305c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski CHECK_BTGATT_INIT(); 1306c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski rssi_request_client_if = client_if; 1307c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski // Closure will own this value and free it. 1308c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski uint8_t *address = new BD_ADDR; 1309c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski bdcpy(address, bd_addr->address); 1310c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski return do_in_jni_thread(Bind(base::IgnoreResult(&BTM_ReadRSSI), 1311c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski base::Owned(address), 1312c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski (tBTM_CMPL_CB *)btm_read_rssi_cb)); 1313ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1314ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1315c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowskistatic bt_status_t btif_gattc_configure_mtu(int conn_id, int mtu) { 1316c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski CHECK_BTGATT_INIT(); 1317c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski return do_in_jni_thread( 1318c9fe4b6f62c95b195fa99c4fbb75863e547929bfJakub Pawlowski Bind(base::IgnoreResult(&BTA_GATTC_ConfigureMTU), conn_id, mtu)); 13199426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach} 13209426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach 13217cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowskivoid btif_gattc_conn_parameter_update_impl(const BD_ADDR addr, int min_interval, 13227cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski int max_interval, int latency, 13237cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski int timeout) { 13247cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski if (BTA_DmGetConnectionState(const_cast<UINT8 *>(addr))) 13257cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski BTA_DmBleUpdateConnectionParams(const_cast<UINT8 *>(addr), min_interval, 13267cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski max_interval, latency, timeout); 13277cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski else 13287cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski BTA_DmSetBlePrefConnParams(const_cast<UINT8 *>(addr), min_interval, 13297cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski max_interval, latency, timeout); 13307cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski} 13317cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski 13327cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowskistatic bt_status_t btif_gattc_conn_parameter_update(const bt_bdaddr_t *bd_addr, 13337cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski int min_interval, 13347cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski int max_interval, 13357cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski int latency, int timeout) { 13367cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski CHECK_BTGATT_INIT(); 13377cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski return do_in_jni_thread( 13387cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski Bind(base::IgnoreResult(&btif_gattc_conn_parameter_update_impl), 13397cb29a38027f9cb24fc30eefb389f848cfc17082Jakub Pawlowski bd_addr->address, min_interval, max_interval, latency, timeout)); 134052a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach} 134152a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach 13421a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowskistatic void btif_gattc_scan_filter_param_setup_impl( 13431a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski int client_if, uint8_t action, int filt_index, 13441a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski tBTA_DM_BLE_PF_FILT_PARAMS *adv_filt_param) { 13451a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski if (1 == adv_filt_param->dely_mode) 13461a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski BTA_DmBleTrackAdvertiser(client_if, bta_track_adv_event_cb); 13471a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski BTA_DmBleScanFilterSetup(action, filt_index, adv_filt_param, NULL, 13481a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski bta_scan_filt_param_setup_cb, client_if); 13491a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski} 13501a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski 13511a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowskistatic bt_status_t btif_gattc_scan_filter_param_setup( 13521a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski btgatt_filt_param_setup_t filt_param) { 13531a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski CHECK_BTGATT_INIT(); 13541a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski BTIF_TRACE_DEBUG("%s", __FUNCTION__); 13551a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski 13561a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski tBTA_DM_BLE_PF_FILT_PARAMS *adv_filt_param = new tBTA_DM_BLE_PF_FILT_PARAMS; 13571a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski adv_filt_param->feat_seln = filt_param.feat_seln; 13581a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski adv_filt_param->list_logic_type = filt_param.list_logic_type; 13591a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski adv_filt_param->filt_logic_type = filt_param.filt_logic_type; 13601a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski adv_filt_param->rssi_high_thres = filt_param.rssi_high_thres; 13611a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski adv_filt_param->rssi_low_thres = filt_param.rssi_low_thres; 13621a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski adv_filt_param->dely_mode = filt_param.dely_mode; 13631a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski adv_filt_param->found_timeout = filt_param.found_timeout; 13641a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski adv_filt_param->lost_timeout = filt_param.lost_timeout; 13651a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski adv_filt_param->found_timeout_cnt = filt_param.found_timeout_cnt; 13661a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski adv_filt_param->num_of_tracking_entries = filt_param.num_of_tracking_entries; 13671a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski 13681a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski return do_in_jni_thread( 13691a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski Bind(base::IgnoreResult(&btif_gattc_scan_filter_param_setup_impl), 13701a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski filt_param.client_if, filt_param.action, filt_param.filt_index, 13711a9e2ac4dab5a74139613f4ff5dde1b979522f0eJakub Pawlowski base::Owned(adv_filt_param))); 1372b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach} 1373b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach 1374904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowskivoid btif_gattc_scan_filter_add_srvc_uuid(tBT_UUID uuid, 1375904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski tBTA_DM_BLE_PF_COND_MASK *p_uuid_mask, 1376904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski int action, int filt_type, 1377904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski int filt_index, int client_if) { 1378904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski tBTA_DM_BLE_PF_COND_PARAM cond; 1379904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski memset(&cond, 0, sizeof(tBTA_DM_BLE_PF_COND_PARAM)); 1380904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1381904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.srvc_uuid.p_target_addr = NULL; 1382904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.srvc_uuid.cond_logic = BTA_DM_BLE_PF_LOGIC_AND; 1383904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.srvc_uuid.uuid = uuid; 1384904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.srvc_uuid.p_uuid_mask = p_uuid_mask; 1385904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1386904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski BTA_DmBleCfgFilterCondition(action, filt_type, filt_index, &cond, 1387904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski &bta_scan_filt_cfg_cb, client_if); 1388904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski} 1389904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1390904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowskivoid btif_gattc_scan_filter_add_local_name(uint8_t *data, int data_len, 1391904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski int action, int filt_type, 1392904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski int filt_index, int client_if) { 1393904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski tBTA_DM_BLE_PF_COND_PARAM cond; 1394904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski memset(&cond, 0, sizeof(tBTA_DM_BLE_PF_COND_PARAM)); 1395904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1396904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.local_name.data_len = data_len; 1397904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.local_name.p_data = data; 1398904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski BTA_DmBleCfgFilterCondition(action, filt_type, filt_index, &cond, 1399904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski &bta_scan_filt_cfg_cb, client_if); 1400904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski} 1401904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1402904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowskivoid btif_gattc_scan_filter_add_manu_data(int company_id, int company_id_mask, 1403904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski uint8_t *pattern, int pattern_len, 1404904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski uint8_t *pattern_mask, int action, 1405904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski int filt_type, int filt_index, 1406904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski int client_if) { 1407904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski tBTA_DM_BLE_PF_COND_PARAM cond; 1408904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski memset(&cond, 0, sizeof(tBTA_DM_BLE_PF_COND_PARAM)); 1409904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1410904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.manu_data.company_id = company_id; 1411904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.manu_data.company_id_mask = company_id_mask ? company_id_mask : 0xFFFF; 1412904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.manu_data.data_len = pattern_len; 1413904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.manu_data.p_pattern = pattern; 1414904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.manu_data.p_pattern_mask = pattern_mask; 1415904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski BTA_DmBleCfgFilterCondition(action, filt_type, filt_index, &cond, 1416904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski &bta_scan_filt_cfg_cb, client_if); 1417904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski} 1418904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1419904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowskivoid btif_gattc_scan_filter_add_data_pattern(uint8_t *pattern, int pattern_len, 1420904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski uint8_t *pattern_mask, int action, 1421904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski int filt_type, int filt_index, 1422904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski int client_if) { 1423904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski tBTA_DM_BLE_PF_COND_PARAM cond; 1424904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski memset(&cond, 0, sizeof(tBTA_DM_BLE_PF_COND_PARAM)); 1425904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1426904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.srvc_data.data_len = pattern_len; 1427904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.srvc_data.p_pattern = pattern; 1428904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond.srvc_data.p_pattern_mask = pattern_mask; 1429904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski BTA_DmBleCfgFilterCondition(action, filt_type, filt_index, &cond, 1430904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski &bta_scan_filt_cfg_cb, client_if); 1431904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski} 1432904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1433904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowskistatic bt_status_t btif_gattc_scan_filter_add_remove( 1434904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski int client_if, int action, int filt_type, int filt_index, int company_id, 1435904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski int company_id_mask, const bt_uuid_t *p_uuid, const bt_uuid_t *p_uuid_mask, 1436904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski const bt_bdaddr_t *bd_addr, char addr_type, int data_len, char *p_data, 1437904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski int mask_len, char *p_mask) { 1438904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski CHECK_BTGATT_INIT(); 1439904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski BTIF_TRACE_DEBUG("%s, %d, %d", __FUNCTION__, action, filt_type); 1440904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1441904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski /* If data is passed, both mask and data have to be the same length */ 1442904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski if (data_len != mask_len && NULL != p_data && NULL != p_mask) 1443904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski return BT_STATUS_PARM_INVALID; 1444904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1445904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski switch (filt_type) { 1446904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski case BTA_DM_BLE_PF_ADDR_FILTER: // 0 1447904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski { 1448904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski tBTA_DM_BLE_PF_COND_PARAM *cond = new tBTA_DM_BLE_PF_COND_PARAM; 1449904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski memset(cond, 0, sizeof(tBTA_DM_BLE_PF_COND_PARAM)); 1450904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1451904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski bdcpy(cond->target_addr.bda, bd_addr->address); 1452904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond->target_addr.type = addr_type; 1453904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition, action, 1454904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski filt_type, filt_index, base::Owned(cond), 1455904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski &bta_scan_filt_cfg_cb, client_if)); 1456904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski } 1457904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1458904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski case BTA_DM_BLE_PF_SRVC_DATA: // 1 1459904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition, action, 1460904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski filt_type, filt_index, nullptr, 1461904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski &bta_scan_filt_cfg_cb, client_if)); 1462904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1463904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski case BTA_DM_BLE_PF_SRVC_UUID: // 2 1464904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski { 1465904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski tBT_UUID bt_uuid; 1466904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski btif_to_bta_uuid(&bt_uuid, p_uuid); 1467904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1468904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski if (p_uuid_mask != NULL) { 1469904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski tBTA_DM_BLE_PF_COND_MASK *uuid_mask = new tBTA_DM_BLE_PF_COND_MASK; 1470904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski btif_to_bta_uuid_mask(uuid_mask, p_uuid_mask); 1471904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_srvc_uuid, 1472904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski bt_uuid, base::Owned(uuid_mask), action, 1473904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski filt_type, filt_index, client_if)); 1474904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski } 1475904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1476904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_srvc_uuid, 1477904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski bt_uuid, nullptr, action, filt_type, 1478904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski filt_index, client_if)); 1479904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski } 1480904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1481904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski case BTA_DM_BLE_PF_SRVC_SOL_UUID: // 3 1482904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski { 1483904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski tBTA_DM_BLE_PF_COND_PARAM *cond = new tBTA_DM_BLE_PF_COND_PARAM; 1484904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski memset(cond, 0, sizeof(tBTA_DM_BLE_PF_COND_PARAM)); 1485904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1486904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond->solicitate_uuid.p_target_addr = NULL; 1487904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski cond->solicitate_uuid.cond_logic = BTA_DM_BLE_PF_LOGIC_AND; 1488904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski btif_to_bta_uuid(&cond->solicitate_uuid.uuid, p_uuid); 1489904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1490904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition, action, 1491904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski filt_type, filt_index, base::Owned(cond), 1492904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski &bta_scan_filt_cfg_cb, client_if)); 1493904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski } 1494904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1495904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski case BTA_DM_BLE_PF_LOCAL_NAME: // 4 1496904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski { 1497904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski uint8_t *data = new uint8_t[data_len]; 1498904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski memcpy(data, p_data, data_len); 1499904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_local_name, 1500904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski base::Owned(data), data_len, action, 1501904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski filt_type, filt_index, client_if)); 1502904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski } 1503904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1504904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski case BTA_DM_BLE_PF_MANU_DATA: // 5 15051a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji { 1506904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski uint8_t *data = new uint8_t[data_len]; 1507904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski memcpy(data, p_data, data_len); 1508904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1509904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski uint8_t *mask = new uint8_t[data_len]; 1510904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski memcpy(mask, p_mask, data_len); 1511904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski return do_in_jni_thread( 1512904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski Bind(&btif_gattc_scan_filter_add_manu_data, company_id, 1513904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski company_id_mask, base::Owned(data), data_len, base::Owned(mask), 1514904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski action, filt_type, filt_index, client_if)); 15151a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji } 1516904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1517904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski case BTA_DM_BLE_PF_SRVC_DATA_PATTERN: // 6 1518904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski { 1519904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski uint8_t *data = new uint8_t[data_len]; 1520904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski memcpy(data, p_data, data_len); 1521904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1522904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski uint8_t *mask = new uint8_t[data_len]; 1523904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski memcpy(mask, p_mask, data_len); 1524904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1525904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski return do_in_jni_thread(Bind( 1526904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski &btif_gattc_scan_filter_add_data_pattern, base::Owned(data), data_len, 1527904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski base::Owned(mask), action, filt_type, filt_index, client_if)); 1528904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski } 1529904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski 1530904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski default: 1531904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski LOG_ERROR(LOG_TAG, "%s: Unknown filter type (%d)!", __func__, action); 1532904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski return (bt_status_t)BTA_GATT_OK; 1533904aefe1a9c2808a7460ebb9896391acdaa39f4eJakub Pawlowski } 1534b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach} 1535b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach 153671d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowskistatic bt_status_t btif_gattc_scan_filter_clear(int client_if, int filter_index) { 153771d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski CHECK_BTGATT_INIT(); 153871d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski BTIF_TRACE_DEBUG("%s: filter_index: %d", __FUNCTION__, filter_index); 15391a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji 154071d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition, 154171d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski BTA_DM_BLE_SCAN_COND_CLEAR, 154271d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski BTA_DM_BLE_PF_TYPE_ALL, filter_index, nullptr, 154371d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski &bta_scan_filt_cfg_cb, client_if)); 15441a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji} 15451a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji 154671d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowskistatic bt_status_t btif_gattc_scan_filter_enable(int client_if, bool enable) { 154771d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski CHECK_BTGATT_INIT(); 154871d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski BTIF_TRACE_DEBUG("%s: enable: %d", __FUNCTION__, enable); 15491a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji 155071d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski uint8_t action = enable ? 1: 0; 155171d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski 155271d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski return do_in_jni_thread(Bind(&BTA_DmEnableScanFilter, action, 155371d4e33a08a5eaf458c4cd3de1ca65a542be81e3Jakub Pawlowski &bta_scan_filt_status_cb, client_if)); 1554b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach} 1555b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach 15564c634eeafc79e68b40ff1ade0d96ba7b1c34f85fJakub Pawlowskistatic bt_status_t btif_gattc_set_scan_parameters(int client_if, 15574c634eeafc79e68b40ff1ade0d96ba7b1c34f85fJakub Pawlowski int scan_interval, 15584c634eeafc79e68b40ff1ade0d96ba7b1c34f85fJakub Pawlowski int scan_window) { 15594c634eeafc79e68b40ff1ade0d96ba7b1c34f85fJakub Pawlowski CHECK_BTGATT_INIT(); 15604c634eeafc79e68b40ff1ade0d96ba7b1c34f85fJakub Pawlowski return do_in_jni_thread( 15614c634eeafc79e68b40ff1ade0d96ba7b1c34f85fJakub Pawlowski Bind(BTA_DmSetBleScanParams, client_if, scan_interval, scan_window, 15624c634eeafc79e68b40ff1ade0d96ba7b1c34f85fJakub Pawlowski BTM_BLE_SCAN_MODE_ACTI, 15634c634eeafc79e68b40ff1ade0d96ba7b1c34f85fJakub Pawlowski (tBLE_SCAN_PARAM_SETUP_CBACK)bta_scan_param_setup_cb)); 15647d208f286865ff58ba5e79299c42b9686cca25cbPrerepa Viswanadham} 15657d208f286865ff58ba5e79299c42b9686cca25cbPrerepa Viswanadham 1566ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic int btif_gattc_get_device_type( const bt_bdaddr_t *bd_addr ) 1567ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 1568ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int device_type = 0; 1569ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta char bd_addr_str[18] = {0}; 1570ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 15718a6a89faa942aed4f176b0c98402d01c8bdd6aa6Sharvil Nanavati bdaddr_to_string(bd_addr, bd_addr_str, sizeof(bd_addr_str)); 15729d52f88bfc07556cb01ab3055f5b1242c9b467aaSharvil Nanavati if (btif_config_get_int(bd_addr_str, "DevType", &device_type)) 1573ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return device_type; 1574ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return 0; 1575ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1576ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 15773a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowskistatic void btif_gattc_multi_adv_enable_impl(int client_if, int min_interval, 15783a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski int max_interval, int adv_type, 15793a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski int chnl_map, int tx_power, 15803a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski int timeout_s) { 15813a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski tBTA_BLE_ADV_PARAMS param; 15823a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski param.adv_int_min = min_interval; 15833a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski param.adv_int_max = max_interval; 15843a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski param.adv_type = adv_type; 15853a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski param.channel_map = chnl_map; 15863a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski param.adv_filter_policy = 0; 15873a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski param.tx_power = tx_power; 15883a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski 15893a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski int cbindex = -1; 15903a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski int arrindex = btif_multi_adv_add_instid_map(client_if, INVALID_ADV_INST, true); 15913a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski if (arrindex >= 0) 15923a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski cbindex = btif_gattc_obtain_idx_for_datacb(client_if, CLNT_IF_IDX); 15933a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski 15943a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski if (cbindex >= 0 && arrindex >= 0) { 15953a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski btgatt_multi_adv_common_data *p_multi_adv_data_cb = 15963a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski btif_obtain_multi_adv_data_cb(); 15973a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski memcpy(&p_multi_adv_data_cb->inst_cb[cbindex].param, ¶m, 15983a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski sizeof(tBTA_BLE_ADV_PARAMS)); 15993a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski p_multi_adv_data_cb->inst_cb[cbindex].timeout_s = timeout_s; 16003a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski BTIF_TRACE_DEBUG("%s, client_if value: %d", __FUNCTION__, 16013a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski p_multi_adv_data_cb->clntif_map[arrindex + arrindex]); 16023a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski BTA_BleEnableAdvInstance( 16033a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski &(p_multi_adv_data_cb->inst_cb[cbindex].param), 16043a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski bta_gattc_multi_adv_cback, 16053a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski &(p_multi_adv_data_cb->clntif_map[arrindex + arrindex])); 16063a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski } else { 16073a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski // let the error propagate up from BTA layer 16083a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski BTIF_TRACE_ERROR("%s invalid index arrindex: %d, cbindex: %d", 16093a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski __func__, arrindex, cbindex); 16103a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski BTA_BleEnableAdvInstance(¶m, bta_gattc_multi_adv_cback, NULL); 16113a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski } 16123a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski} 16133a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski 16143a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowskistatic bt_status_t btif_gattc_multi_adv_enable(int client_if, int min_interval, 16153a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski int max_interval, int adv_type, 16163a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski int chnl_map, int tx_power, 16173a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski int timeout_s) { 16183a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski CHECK_BTGATT_INIT(); 16193a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski return do_in_jni_thread(Bind(btif_gattc_multi_adv_enable_impl, client_if, 16203a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski min_interval, max_interval, adv_type, chnl_map, 16213a70173f66b9ca3c5ad6260ca963180c479c5d0dJakub Pawlowski tx_power, timeout_s)); 1622a6ce7751d84218c193eb90d390aef23217b1737eWei Wang} 1623a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 16245dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowskistatic void btif_gattc_multi_adv_update_impl(int client_if, int min_interval, 16255dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski int max_interval, int adv_type, 16265dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski int chnl_map, int tx_power) { 16275dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski tBTA_BLE_ADV_PARAMS param; 16285dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski param.adv_int_min = min_interval; 16295dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski param.adv_int_max = max_interval; 16305dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski param.adv_type = adv_type; 16315dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski param.channel_map = chnl_map; 16325dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski param.adv_filter_policy = 0; 16335dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski param.tx_power = tx_power; 16345dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski 16355dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski int inst_id = btif_multi_adv_instid_for_clientif(client_if); 16365dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski int cbindex = btif_gattc_obtain_idx_for_datacb(client_if, CLNT_IF_IDX); 16375dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski if (inst_id >= 0 && cbindex >= 0) { 16385dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski btgatt_multi_adv_common_data *p_multi_adv_data_cb = 16395dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski btif_obtain_multi_adv_data_cb(); 16405dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski memcpy(&p_multi_adv_data_cb->inst_cb[cbindex].param, ¶m, 16415dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski sizeof(tBTA_BLE_ADV_PARAMS)); 16425dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski BTA_BleUpdateAdvInstParam((UINT8)inst_id, 16435dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski &(p_multi_adv_data_cb->inst_cb[cbindex].param)); 16445dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski } else { 16455dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski BTIF_TRACE_ERROR("%s invalid index in BTIF_GATTC_UPDATE_ADV", __FUNCTION__); 16465dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski } 16475dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski} 1648a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 16495dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowskistatic bt_status_t btif_gattc_multi_adv_update(int client_if, int min_interval, 16505dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski int max_interval, int adv_type, 16515dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski int chnl_map, int tx_power, 16525dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski int timeout_s) { 16535dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski CHECK_BTGATT_INIT(); 16545dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski return do_in_jni_thread(Bind(btif_gattc_multi_adv_update_impl, client_if, 16555dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski min_interval, max_interval, adv_type, chnl_map, 16565dfe8ba500ad0594c787a0b905369f36de7da38bJakub Pawlowski tx_power)); 1657a6ce7751d84218c193eb90d390aef23217b1737eWei Wang} 1658a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 1659ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowskistatic void btif_gattc_multi_adv_setdata_impl(btif_adv_data_t *p_adv_data) { 1660ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski int cbindex = 1661ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski btif_gattc_obtain_idx_for_datacb(p_adv_data->client_if, CLNT_IF_IDX); 1662ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski int inst_id = btif_multi_adv_instid_for_clientif(p_adv_data->client_if); 1663ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski if (inst_id >= 0 && cbindex >= 0 && 1664ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski btif_gattc_copy_datacb(cbindex, p_adv_data, true)) { 1665ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski btgatt_multi_adv_common_data *p_multi_adv_data_cb = 1666ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski btif_obtain_multi_adv_data_cb(); 1667ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski BTA_BleCfgAdvInstData((UINT8)inst_id, p_adv_data->set_scan_rsp, 1668ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski p_multi_adv_data_cb->inst_cb[cbindex].mask, 1669ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski &p_multi_adv_data_cb->inst_cb[cbindex].data); 1670ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski } else { 1671ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski BTIF_TRACE_ERROR( 1672ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski "%s: failed to get invalid instance data: inst_id:%d cbindex:%d", 1673ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski __func__, inst_id, cbindex); 1674ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski } 1675ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski} 1676a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 1677ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowskistatic bt_status_t btif_gattc_multi_adv_setdata( 1678ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski int client_if, bool set_scan_rsp, bool include_name, bool incl_txpower, 1679ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski int appearance, int manufacturer_len, char *manufacturer_data, 1680ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski int service_data_len, char *service_data, int service_uuid_len, 1681ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski char *service_uuid) { 1682ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski CHECK_BTGATT_INIT(); 16830d45f25e4102b14d942efa530f0e6a1a6c19787aIan Coolidge 1684ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski btif_adv_data_t *multi_adv_data_inst = new btif_adv_data_t; 1685a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 1686ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski const int min_interval = 0; 1687ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski const int max_interval = 0; 1688a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 1689ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski btif_gattc_adv_data_packager(client_if, set_scan_rsp, include_name, 1690ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski incl_txpower, min_interval, max_interval, 1691ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski appearance, manufacturer_len, manufacturer_data, 1692ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski service_data_len, service_data, service_uuid_len, 1693ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski service_uuid, multi_adv_data_inst); 1694ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski 1695ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski return do_in_jni_thread(Bind(&btif_gattc_multi_adv_setdata_impl, 1696ed8aefe6134359cc70b127a23bac3a6d4c24065eJakub Pawlowski base::Owned(multi_adv_data_inst))); 1697a6ce7751d84218c193eb90d390aef23217b1737eWei Wang} 1698a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 1699772fc669dcf1221df03377e5c16507f2f7caa91bJakub Pawlowskistatic void btif_gattc_multi_adv_disable_impl(int client_if) { 1700772fc669dcf1221df03377e5c16507f2f7caa91bJakub Pawlowski int inst_id = btif_multi_adv_instid_for_clientif(client_if); 1701772fc669dcf1221df03377e5c16507f2f7caa91bJakub Pawlowski if (inst_id >= 0) 1702772fc669dcf1221df03377e5c16507f2f7caa91bJakub Pawlowski BTA_BleDisableAdvInstance((UINT8)inst_id); 1703772fc669dcf1221df03377e5c16507f2f7caa91bJakub Pawlowski else 1704772fc669dcf1221df03377e5c16507f2f7caa91bJakub Pawlowski BTIF_TRACE_ERROR("%s invalid instance ID", __func__); 1705772fc669dcf1221df03377e5c16507f2f7caa91bJakub Pawlowski} 1706a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 1707772fc669dcf1221df03377e5c16507f2f7caa91bJakub Pawlowskistatic bt_status_t btif_gattc_multi_adv_disable(int client_if) { 1708772fc669dcf1221df03377e5c16507f2f7caa91bJakub Pawlowski CHECK_BTGATT_INIT(); 1709772fc669dcf1221df03377e5c16507f2f7caa91bJakub Pawlowski return do_in_jni_thread(Bind(btif_gattc_multi_adv_disable_impl, client_if)); 1710a6ce7751d84218c193eb90d390aef23217b1737eWei Wang} 1711a6ce7751d84218c193eb90d390aef23217b1737eWei Wang 17122af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowskistatic bt_status_t btif_gattc_cfg_storage(int client_if, 17132af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski int batch_scan_full_max, 17142af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski int batch_scan_trunc_max, 17152af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski int batch_scan_notify_threshold) { 17162af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski CHECK_BTGATT_INIT(); 17172af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski return do_in_jni_thread( 17182af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski Bind(BTA_DmBleSetStorageParams, batch_scan_full_max, batch_scan_trunc_max, 17192af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski batch_scan_notify_threshold, 17202af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski (tBTA_BLE_SCAN_SETUP_CBACK *)bta_batch_scan_setup_cb, 17212af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski (tBTA_BLE_SCAN_THRESHOLD_CBACK *)bta_batch_scan_threshold_cb, 17222af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski (tBTA_BLE_SCAN_REP_CBACK *)bta_batch_scan_reports_cb, 17232af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski (tBTA_DM_BLE_REF_VALUE)client_if)); 1724c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji} 1725c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 17262af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowskistatic bt_status_t btif_gattc_enb_batch_scan(int client_if, int scan_mode, 17272af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski int scan_interval, int scan_window, 17282af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski int addr_type, int discard_rule) { 17292af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski CHECK_BTGATT_INIT(); 17302af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski return do_in_jni_thread(Bind(BTA_DmBleEnableBatchScan, scan_mode, 17312af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski scan_interval, scan_window, discard_rule, 17322af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski addr_type, client_if)); 1733c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji} 1734c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 17352af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowskistatic bt_status_t btif_gattc_dis_batch_scan(int client_if) { 17362af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski CHECK_BTGATT_INIT(); 17372af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski return do_in_jni_thread(Bind(BTA_DmBleDisableBatchScan, client_if)); 1738c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji} 1739c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 17402af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowskistatic bt_status_t btif_gattc_read_batch_scan_reports(int client_if, 17412af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski int scan_mode) { 17422af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski CHECK_BTGATT_INIT(); 17432af2129df720baee246d4ff9a0f1a02884da856eJakub Pawlowski return do_in_jni_thread(Bind(BTA_DmBleReadScanReports, scan_mode, client_if)); 1744c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji} 1745c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji 1746ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battaextern bt_status_t btif_gattc_test_command_impl(int command, btgatt_test_params_t* params); 1747ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1748ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gattc_test_command(int command, btgatt_test_params_t* params) 1749ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 1750ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_gattc_test_command_impl(command, params); 1751ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 1752ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1753ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battaconst btgatt_client_interface_t btgattClientInterface = { 1754ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_register_app, 1755ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_unregister_app, 1756ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_scan, 1757ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_open, 1758ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_close, 17595c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach btif_gattc_listen, 1760ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_refresh, 1761ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_search_service, 1762ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_read_char, 1763ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_write_char, 1764ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_read_char_descr, 1765ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_write_char_descr, 1766ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_execute_write, 1767ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_reg_for_notification, 1768ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_dereg_for_notification, 1769ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_read_remote_rssi, 17701a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji btif_gattc_scan_filter_param_setup, 17711a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji btif_gattc_scan_filter_add_remove, 1772b203d478f4835f5e35217874a1787e1914328f7cAndre Eisenbach btif_gattc_scan_filter_clear, 17731a9247a1229aa65b3d1dce16426177bc5828e54dSatya Calloji btif_gattc_scan_filter_enable, 1774ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gattc_get_device_type, 17755c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach btif_gattc_set_adv_data, 17769426d530e9bbc5d3ffae55515388d49185c61325Andre Eisenbach btif_gattc_configure_mtu, 177752a2cd609897c04bb6440e14ef2ec8871143d028Andre Eisenbach btif_gattc_conn_parameter_update, 17787d208f286865ff58ba5e79299c42b9686cca25cbPrerepa Viswanadham btif_gattc_set_scan_parameters, 1779a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_gattc_multi_adv_enable, 1780a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_gattc_multi_adv_update, 1781a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_gattc_multi_adv_setdata, 1782a6ce7751d84218c193eb90d390aef23217b1737eWei Wang btif_gattc_multi_adv_disable, 1783c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_gattc_cfg_storage, 1784c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_gattc_enb_batch_scan, 1785c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_gattc_dis_batch_scan, 1786c4e2596a112a0dd63ac681b1226548c0f95e828cSatya Calloji btif_gattc_read_batch_scan_reports, 1787533fdbf46fb623aefbe4d0107b5cccd41aec097aJakub Pawlowski btif_gattc_test_command, 1788533fdbf46fb623aefbe4d0107b5cccd41aec097aJakub Pawlowski btif_gattc_get_gatt_db 1789ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta}; 1790ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1791ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#endif 1792