btif_gatt_server.c revision ead3cde4bac0c3e32cd31f149093f004eef8ceeb
1ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/****************************************************************************** 2ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * 3ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * Copyright (C) 2009-2013 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 * 22ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * Filename: btif_gatt_server.c 23ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * 24ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * Description: GATT server implementation 25ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta * 26ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ***********************************************************************************/ 27ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 28ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include <hardware/bluetooth.h> 29ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include <hardware/bt_gatt.h> 30ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include <stdio.h> 31ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include <stdlib.h> 32ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include <errno.h> 33ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include <string.h> 34ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 35ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#define LOG_TAG "BtGatt.btif" 36ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 37ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_common.h" 38ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_util.h" 39ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 40ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 41ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 42ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "bta_api.h" 43ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "bta_gatt_api.h" 44ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "bd.h" 45ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_dm.h" 46ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_storage.h" 47ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 48ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_gatt.h" 49ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_gatt_util.h" 50ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 51ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/************************************************************************************ 52ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Constants & Macros 53ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta************************************************************************************/ 54ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 55ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#define CHECK_BTGATT_INIT() if (bt_gatt_callbacks == NULL)\ 56ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta {\ 57ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ALOGW("%s: BTGATT not initialized", __FUNCTION__);\ 58ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return BT_STATUS_NOT_READY;\ 59ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } else {\ 60ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ALOGD("%s", __FUNCTION__);\ 61ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 62ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 63ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 64ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battatypedef enum { 65ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_REGISTER_APP = 2000, 66ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_UNREGISTER_APP, 67ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_OPEN, 68ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_CLOSE, 69ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_CREATE_SERVICE, 70ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_ADD_INCLUDED_SERVICE, 71ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_ADD_CHARACTERISTIC, 72ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_ADD_DESCRIPTOR, 73ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_START_SERVICE, 74ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_STOP_SERVICE, 75ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_DELETE_SERVICE, 76ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_SEND_INDICATION, 77ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_GATTS_SEND_RESPONSE 78ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} btif_gatts_event_t; 79ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 80ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/************************************************************************************ 81ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Local type definitions 82ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta************************************************************************************/ 83ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 84ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battatypedef struct 85ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 86ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t value[BTGATT_MAX_ATTR_LEN]; 87ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btgatt_response_t response; 88ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btgatt_srvc_id_t srvc_id; 89ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bd_addr; 90ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_uuid_t uuid; 91ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint32_t trans_id; 92ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint16_t conn_id; 93ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint16_t srvc_handle; 94ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint16_t incl_handle; 95ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint16_t attr_handle; 96ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint16_t permissions; 97ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint16_t len; 98ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t server_if; 99ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t is_direct; 100ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t num_handles; 101ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t properties; 102ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t transport; 103ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t confirm; 104ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t status; 105ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} __attribute__((packed)) btif_gatts_cb_t; 106ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 107ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 108ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/************************************************************************************ 109ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Static variables 110ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta************************************************************************************/ 111ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 112ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battaextern const btgatt_callbacks_t *bt_gatt_callbacks; 113ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 114ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 115ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/************************************************************************************ 116ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Static functions 117ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta************************************************************************************/ 118ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 119ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btapp_gatts_handle_cback(uint16_t event, char* p_param) 120ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 121ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ALOGD("%s: Event %d", __FUNCTION__, event); 122ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 123ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta tBTA_GATTS *p_data = (tBTA_GATTS*)p_param; 124ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta switch (event) 125ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 126ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_REG_EVT: 127ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 128ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_uuid_t app_uuid; 129ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bta_to_btif_uuid(&app_uuid, &p_data->reg_oper.uuid); 130ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->register_server_cb 131ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , p_data->reg_oper.status 132ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , p_data->reg_oper.server_if 133ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta , &app_uuid 134ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ); 135ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 136ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 137ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 138ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_DEREG_EVT: 139ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 140ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 141ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_CONNECT_EVT: 142ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 143ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bda; 144ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bda.address, p_data->conn.remote_bda); 145ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 146ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatt_check_encrypted_link(p_data->conn.remote_bda); 147ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 148ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->connection_cb, 149ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->conn.conn_id, TRUE, &bda); 150ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 151ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 152ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 153ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_DISCONNECT_EVT: 154ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 155ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bda; 156ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bda.address, p_data->conn.remote_bda); 157ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 158ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->connection_cb, 159ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->conn.conn_id, FALSE, &bda); 160ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 161ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatt_remove_encrypted_link(p_data->conn.remote_bda); 162ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 163ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 164ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 165ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_CREATE_EVT: 166ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 167ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btgatt_srvc_id_t srvc_id; 168ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta srvc_id.is_primary = p_data->create.is_primary; 169ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta srvc_id.id.inst_id = p_data->create.svc_instance; 170ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bta_to_btif_uuid(&srvc_id.id.uuid, &p_data->create.uuid); 171ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 172ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->service_added_cb, 173ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->create.status, p_data->create.server_if, &srvc_id, 174ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->create.service_id 175ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ); 176ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 177ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 178ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 179ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_ADD_INCL_SRVC_EVT: 180ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->included_service_added_cb, 181ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.status, 182ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.server_if, 183ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.service_id, 184ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.attr_id); 185ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 186ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 187ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_ADD_CHAR_EVT: 188ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 189ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_uuid_t uuid; 190ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bta_to_btif_uuid(&uuid, &p_data->add_result.char_uuid); 191ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 192ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->characteristic_added_cb, 193ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.status, 194ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.server_if, 195ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta &uuid, 196ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.service_id, 197ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.attr_id); 198ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 199ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 200ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 201ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_ADD_CHAR_DESCR_EVT: 202ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 203ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_uuid_t uuid; 204ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bta_to_btif_uuid(&uuid, &p_data->add_result.char_uuid); 205ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 206ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->descriptor_added_cb, 207ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.status, 208ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.server_if, 209ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta &uuid, 210ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.service_id, 211ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->add_result.attr_id); 212ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 213ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 214ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 215ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_START_EVT: 216ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->service_started_cb, 217ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->srvc_oper.status, 218ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->srvc_oper.server_if, 219ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->srvc_oper.service_id); 220ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 221ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 222ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_STOP_EVT: 223ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->service_stopped_cb, 224ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->srvc_oper.status, 225ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->srvc_oper.server_if, 226ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->srvc_oper.service_id); 227ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 228ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 229ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_DELELTE_EVT: 230ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->service_deleted_cb, 231ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->srvc_oper.status, 232ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->srvc_oper.server_if, 233ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->srvc_oper.service_id); 234ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 235ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 236ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_READ_EVT: 237ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 238ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bda; 239ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bda.address, p_data->req_data.remote_bda); 240ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 241ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->request_read_cb, 242ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.conn_id,p_data->req_data.trans_id, &bda, 243ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.p_data->read_req.handle, 244ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.p_data->read_req.offset, 245ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.p_data->read_req.is_long); 246ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 247ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 248ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 249ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_WRITE_EVT: 250ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 251ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bda; 252ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bda.address, p_data->req_data.remote_bda); 253ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 254ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->request_write_cb, 255ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.conn_id,p_data->req_data.trans_id, &bda, 256ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.p_data->write_req.handle, 257ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.p_data->write_req.offset, 258ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.p_data->write_req.len, 259ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.p_data->write_req.need_rsp, 260ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.p_data->write_req.is_prep, 261ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.p_data->write_req.value); 262ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 263ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 264ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 265ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_EXEC_WRITE_EVT: 266ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 267ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bda; 268ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bda.address, p_data->req_data.remote_bda); 269ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 270ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->request_exec_write_cb, 271ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.conn_id,p_data->req_data.trans_id, &bda, 272ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->req_data.p_data->exec_write); 273ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 274ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 275ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 276ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_MTU_EVT: 277ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_OPEN_EVT: 278ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_CANCEL_OPEN_EVT: 279ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_GATTS_CLOSE_EVT: 280ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ALOGD("%s: Empty event (%d)!", __FUNCTION__, event); 281ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 282ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 283ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta default: 284ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ALOGE("%s: Unhandled event (%d)!", __FUNCTION__, event); 285ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 286ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 287ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 288ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 289ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btapp_gatts_cback(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) 290ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 291ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_status_t status; 292ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta status = btif_transfer_context(btapp_gatts_handle_cback, (uint16_t) event, 293ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (void*)p_data, sizeof(tBTA_GATTS), NULL); 294ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ASSERTC(status == BT_STATUS_SUCCESS, "Context transfer failed!", status); 295ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 296ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 297ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btgatts_handle_event(uint16_t event, char* p_param) 298ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 299ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t* p_cb = (btif_gatts_cb_t*)p_param; 300ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (!p_cb) return; 301ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 302ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ALOGD("%s: Event %d", __FUNCTION__, event); 303ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 304ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta switch (event) 305ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 306ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_REGISTER_APP: 307ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 308ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta tBT_UUID uuid; 309ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_to_bta_uuid(&uuid, &p_cb->uuid); 310ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_AppRegister(&uuid, btapp_gatts_cback); 311ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 312ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 313ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 314ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_UNREGISTER_APP: 315ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_AppDeregister(p_cb->server_if); 316ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 317ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 318ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_OPEN: 319ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (!p_cb->is_direct) 320ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL); 321ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_Open(p_cb->server_if, p_cb->bd_addr.address, 322ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_cb->is_direct); 323ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 324ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 325ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_CLOSE: 326ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta // Cancel pending foreground/background connections 327ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_CancelOpen(p_cb->server_if, p_cb->bd_addr.address, TRUE); 328ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_CancelOpen(p_cb->server_if, p_cb->bd_addr.address, FALSE); 329ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 330ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta // Close active connection 331ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (p_cb->conn_id != 0) 332ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_Close(p_cb->conn_id); 333ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 334ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 335ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_CREATE_SERVICE: 336ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 337ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta tBTA_GATT_SRVC_ID srvc_id; 338ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_to_bta_srvc_id(&srvc_id, &p_cb->srvc_id); 339ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_CreateService(p_cb->server_if, &srvc_id.id.uuid, 340ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta srvc_id.id.inst_id, p_cb->num_handles, 341ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta srvc_id.is_primary); 342ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 343ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 344ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 345ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_ADD_INCLUDED_SERVICE: 346ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_AddIncludeService(p_cb->srvc_handle, p_cb->incl_handle); 347ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 348ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 349ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_ADD_CHARACTERISTIC: 350ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 351ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta tBT_UUID uuid; 352ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_to_bta_uuid(&uuid, &p_cb->uuid); 353ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 354ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_AddCharacteristic(p_cb->srvc_handle, &uuid, 355ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_cb->permissions, p_cb->properties); 356ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 357ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 358ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 359ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_ADD_DESCRIPTOR: 360ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 361ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta tBT_UUID uuid; 362ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_to_bta_uuid(&uuid, &p_cb->uuid); 363ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 364ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_AddCharDescriptor(p_cb->srvc_handle, p_cb->permissions, 365ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta &uuid); 366ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 367ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 368ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 369ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_START_SERVICE: 370ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_StartService(p_cb->srvc_handle, p_cb->transport); 371ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 372ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 373ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_STOP_SERVICE: 374ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_StopService(p_cb->srvc_handle); 375ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 376ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 377ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_DELETE_SERVICE: 378ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_DeleteService(p_cb->srvc_handle); 379ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 380ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 381ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_SEND_INDICATION: 382ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_HandleValueIndication(p_cb->conn_id, p_cb->attr_handle, 383ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_cb->len, p_cb->value, p_cb->confirm); 384ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta // TODO: Might need to send an ACK if handle value indication is 385ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta // invoked without need for confirmation. 386ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 387ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 388ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_GATTS_SEND_RESPONSE: 389ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 390ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta tBTA_GATTS_RSP rsp_struct; 391ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btgatt_response_t *p_rsp = &p_cb->response; 392ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_to_bta_response(&rsp_struct, p_rsp); 393ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 394ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTS_SendRsp(p_cb->conn_id, p_cb->trans_id, 395ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_cb->status, &rsp_struct); 396ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 397ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_gatt_callbacks, server->response_confirmation_cb, 398ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 0, rsp_struct.attr_value.handle); 399ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 400ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 401ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 402ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta default: 403ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ALOGE("%s: Unknown event (%d)!", __FUNCTION__, event); 404ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 405ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 406ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 407ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 408ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/************************************************************************************ 409ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Server API Functions 410ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta************************************************************************************/ 411ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 412ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_register_app(bt_uuid_t *uuid) 413ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 414ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 415ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 416ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&btif_cb.uuid, uuid, sizeof(bt_uuid_t)); 417ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_REGISTER_APP, 418ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 419ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 420ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 421ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_unregister_app( int server_if ) 422ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 423ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 424ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 425ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.server_if = (uint8_t) server_if; 426ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_UNREGISTER_APP, 427ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 428ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 429ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 430ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_open( int server_if, const bt_bdaddr_t *bd_addr, bool is_direct ) 431ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 432ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 433ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 434ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.server_if = (uint8_t) server_if; 435ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.is_direct = is_direct ? 1 : 0; 436ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(btif_cb.bd_addr.address, bd_addr->address); 437ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_OPEN, 438ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 439ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 440ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 441ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_close(int server_if, const bt_bdaddr_t *bd_addr, int conn_id) 442ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 443ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 444ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 445ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.server_if = (uint8_t) server_if; 446ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.conn_id = (uint16_t) conn_id; 447ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(btif_cb.bd_addr.address, bd_addr->address); 448ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_CLOSE, 449ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 450ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 451ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 452ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_add_service(int server_if, btgatt_srvc_id_t *srvc_id, 453ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int num_handles) 454ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 455ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 456ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 457ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.server_if = (uint8_t) server_if; 458ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.num_handles = (uint8_t) num_handles; 459ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&btif_cb.srvc_id, srvc_id, sizeof(btgatt_srvc_id_t)); 460ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_CREATE_SERVICE, 461ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 462ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 463ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 464ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_add_included_service(int server_if, int service_handle, 465ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int included_handle) 466ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 467ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 468ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 469ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.server_if = (uint8_t) server_if; 470ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.srvc_handle = (uint16_t) service_handle; 471ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.incl_handle = (uint16_t) included_handle; 472ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_ADD_INCLUDED_SERVICE, 473ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 474ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 475ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 476ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_add_characteristic(int server_if, int service_handle, 477ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_uuid_t *uuid, int properties, 478ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int permissions) 479ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 480ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 481ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 482ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.server_if = (uint8_t) server_if; 483ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.srvc_handle = (uint16_t) service_handle; 484ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.properties = (uint8_t) properties; 485ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.permissions = (uint16_t) permissions; 486ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&btif_cb.uuid, uuid, sizeof(bt_uuid_t)); 487ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_ADD_CHARACTERISTIC, 488ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 489ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 490ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 491ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_add_descriptor(int server_if, int service_handle, bt_uuid_t *uuid, 492ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int permissions) 493ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 494ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 495ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 496ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.server_if = (uint8_t) server_if; 497ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.srvc_handle = (uint16_t) service_handle; 498ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.permissions = (uint16_t) permissions; 499ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&btif_cb.uuid, uuid, sizeof(bt_uuid_t)); 500ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_ADD_DESCRIPTOR, 501ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 502ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 503ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 504ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_start_service(int server_if, int service_handle, int transport) 505ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 506ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 507ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 508ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.server_if = (uint8_t) server_if; 509ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.srvc_handle = (uint16_t) service_handle; 510ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.transport = (uint8_t) transport; 511ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_START_SERVICE, 512ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 513ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 514ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 515ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_stop_service(int server_if, int service_handle) 516ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 517ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 518ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 519ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.server_if = (uint8_t) server_if; 520ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.srvc_handle = (uint16_t) service_handle; 521ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_STOP_SERVICE, 522ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 523ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 524ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 525ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_delete_service(int server_if, int service_handle) 526ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 527ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 528ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 529ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.server_if = (uint8_t) server_if; 530ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.srvc_handle = (uint16_t) service_handle; 531ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_DELETE_SERVICE, 532ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 533ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 534ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 535ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_send_indication(int server_if, int attribute_handle, int conn_id, 536ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int len, int confirm, char* p_value) 537ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 538ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 539ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 540ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.server_if = (uint8_t) server_if; 541ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.conn_id = (uint16_t) conn_id; 542ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.attr_handle = attribute_handle; 543ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.confirm = confirm; 544ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.len = len; 545ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(btif_cb.value, p_value, len > BTGATT_MAX_ATTR_LEN ? BTGATT_MAX_ATTR_LEN : len); 546ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_SEND_INDICATION, 547ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 548ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 549ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 550ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic bt_status_t btif_gatts_send_response(int conn_id, int trans_id, 551ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int status, btgatt_response_t *response) 552ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 553ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta CHECK_BTGATT_INIT(); 554ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_cb_t btif_cb; 555ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.conn_id = (uint16_t) conn_id; 556ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.trans_id = (uint32_t) trans_id; 557ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_cb.status = (uint8_t) status; 558ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&btif_cb.response, response, sizeof(btgatt_response_t)); 559ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return btif_transfer_context(btgatts_handle_event, BTIF_GATTS_SEND_RESPONSE, 560ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char*) &btif_cb, sizeof(btif_gatts_cb_t), NULL); 561ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 562ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 563ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battaconst btgatt_server_interface_t btgattServerInterface = { 564ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_register_app, 565ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_unregister_app, 566ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_open, 567ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_close, 568ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_add_service, 569ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_add_included_service, 570ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_add_characteristic, 571ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_add_descriptor, 572ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_start_service, 573ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_stop_service, 574ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_delete_service, 575ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_send_indication, 576ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_gatts_send_response 577ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta}; 578ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 579ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#endif 580