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 * 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 35 #define LOG_TAG "BtGatt.btif" 36 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" 44 #include "bd.h" 45 #include "btif_storage.h" 46 47 #include "btif_gatt.h" 48 #include "btif_gatt_util.h" 49 50 const btgatt_callbacks_t *bt_gatt_callbacks = NULL; 51 52 extern btgatt_client_interface_t btgattClientInterface; 53 extern btgatt_server_interface_t btgattServerInterface; 54 55 /******************************************************************************* 56 ** 57 ** Function btif_gatt_init 58 ** 59 ** Description Initializes the GATT interface 60 ** 61 ** Returns bt_status_t 62 ** 63 *******************************************************************************/ btif_gatt_init(const btgatt_callbacks_t * callbacks)64static bt_status_t btif_gatt_init( const btgatt_callbacks_t* callbacks ) 65 { 66 bt_gatt_callbacks = callbacks; 67 68 return BT_STATUS_SUCCESS; 69 } 70 71 /******************************************************************************* 72 ** 73 ** Function btif_gatt_cleanup 74 ** 75 ** Description Closes the GATT interface 76 ** 77 ** Returns void 78 ** 79 *******************************************************************************/ btif_gatt_cleanup(void)80static void btif_gatt_cleanup( void ) 81 { 82 if (bt_gatt_callbacks) 83 bt_gatt_callbacks = NULL; 84 85 BTA_GATTC_Disable(); 86 BTA_GATTS_Disable(); 87 } 88 89 static const btgatt_interface_t btgattInterface = { 90 sizeof(btgattInterface), 91 92 btif_gatt_init, 93 btif_gatt_cleanup, 94 95 &btgattClientInterface, 96 &btgattServerInterface, 97 }; 98 99 /******************************************************************************* 100 ** 101 ** Function btif_gatt_get_interface 102 ** 103 ** Description Get the gatt callback interface 104 ** 105 ** Returns btgatt_interface_t 106 ** 107 *******************************************************************************/ btif_gatt_get_interface()108const btgatt_interface_t *btif_gatt_get_interface() 109 { 110 return &btgattInterface; 111 } 112 113 #endif 114