blob: 50ebaee546201a240c1104bede59b6f427a5834c [file] [log] [blame]
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -08001/******************************************************************************
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 *
22 * Filename: btif_gatt.c
23 *
24 * Description: GATT Profile Bluetooth Interface
25 *
26 *******************************************************************************/
27
28#include <hardware/bluetooth.h>
29#include <hardware/bt_gatt.h>
30#include <stdio.h>
31#include <stdlib.h>
32#include <errno.h>
33#include <string.h>
34
Chris Mantonf8027002015-03-12 09:22:48 -070035#define LOG_TAG "bt_btif_gatt"
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -080036
37#include "btif_common.h"
38#include "btif_util.h"
39
40#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
41
42#include "bta_api.h"
43#include "bta_gatt_api.h"
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -080044#include "btif_storage.h"
45
46#include "btif_gatt.h"
47#include "btif_gatt_util.h"
48
49const btgatt_callbacks_t *bt_gatt_callbacks = NULL;
50
51extern btgatt_client_interface_t btgattClientInterface;
52extern btgatt_server_interface_t btgattServerInterface;
53
54/*******************************************************************************
55**
56** Function btif_gatt_init
57**
58** Description Initializes the GATT interface
59**
Andre Eisenbache1202ca2013-05-15 04:55:08 -070060** Returns bt_status_t
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -080061**
62*******************************************************************************/
63static bt_status_t btif_gatt_init( const btgatt_callbacks_t* callbacks )
64{
65 bt_gatt_callbacks = callbacks;
66
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -080067 return BT_STATUS_SUCCESS;
68}
69
70/*******************************************************************************
71**
72** Function btif_gatt_cleanup
73**
74** Description Closes the GATT interface
75**
76** Returns void
77**
78*******************************************************************************/
79static void btif_gatt_cleanup( void )
80{
81 if (bt_gatt_callbacks)
82 bt_gatt_callbacks = NULL;
Andre Eisenbache1202ca2013-05-15 04:55:08 -070083
84 BTA_GATTC_Disable();
85 BTA_GATTS_Disable();
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -080086}
87
88static const btgatt_interface_t btgattInterface = {
89 sizeof(btgattInterface),
90
91 btif_gatt_init,
92 btif_gatt_cleanup,
93
94 &btgattClientInterface,
95 &btgattServerInterface,
96};
97
98/*******************************************************************************
99**
100** Function btif_gatt_get_interface
101**
102** Description Get the gatt callback interface
103**
104** Returns btgatt_interface_t
105**
106*******************************************************************************/
107const btgatt_interface_t *btif_gatt_get_interface()
108{
109 return &btgattInterface;
110}
111
112#endif