1/****************************************************************************** 2 * 3 * Copyright (C) 2009-2013 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19/******************************************************************************* 20 * 21 * Filename: btif_gatt.c 22 * 23 * Description: GATT Profile Bluetooth Interface 24 * 25 *******************************************************************************/ 26 27#define LOG_TAG "bt_btif_gatt" 28 29#include <errno.h> 30#include <hardware/bluetooth.h> 31#include <hardware/bt_gatt.h> 32#include <stdio.h> 33#include <stdlib.h> 34#include <string.h> 35 36#include "btif_common.h" 37#include "btif_util.h" 38 39#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 40 41#include "bta_api.h" 42#include "bta_gatt_api.h" 43#include "btif_gatt.h" 44#include "btif_gatt_util.h" 45#include "btif_storage.h" 46 47const btgatt_callbacks_t *bt_gatt_callbacks = NULL; 48 49extern btgatt_client_interface_t btgattClientInterface; 50extern btgatt_server_interface_t btgattServerInterface; 51 52/******************************************************************************* 53** 54** Function btif_gatt_init 55** 56** Description Initializes the GATT interface 57** 58** Returns bt_status_t 59** 60*******************************************************************************/ 61static bt_status_t btif_gatt_init( const btgatt_callbacks_t* callbacks ) 62{ 63 bt_gatt_callbacks = callbacks; 64 65 return BT_STATUS_SUCCESS; 66} 67 68/******************************************************************************* 69** 70** Function btif_gatt_cleanup 71** 72** Description Closes the GATT interface 73** 74** Returns void 75** 76*******************************************************************************/ 77static void btif_gatt_cleanup( void ) 78{ 79 if (bt_gatt_callbacks) 80 bt_gatt_callbacks = NULL; 81 82 BTA_GATTC_Disable(); 83 BTA_GATTS_Disable(); 84} 85 86static const btgatt_interface_t btgattInterface = { 87 sizeof(btgattInterface), 88 89 btif_gatt_init, 90 btif_gatt_cleanup, 91 92 &btgattClientInterface, 93 &btgattServerInterface, 94}; 95 96/******************************************************************************* 97** 98** Function btif_gatt_get_interface 99** 100** Description Get the gatt callback interface 101** 102** Returns btgatt_interface_t 103** 104*******************************************************************************/ 105const btgatt_interface_t *btif_gatt_get_interface() 106{ 107 return &btgattInterface; 108} 109 110#endif 111