Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.bluetooth; |
| 18 | |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 19 | /** |
| 20 | * This abstract class is used to implement {@link BluetoothGatt} callbacks. |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 21 | */ |
| 22 | public abstract class BluetoothGattCallback { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 23 | |
| 24 | /** |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 25 | * Callback indicating when GATT client has connected/disconnected to/from a remote |
| 26 | * GATT server. |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 27 | * |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 28 | * @param gatt GATT client |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 29 | * @param status Status of the connect or disconnect operation. |
| 30 | * @param newState Returns the new connection state. Can be one of |
| 31 | * {@link BluetoothProfile#STATE_DISCONNECTED} or |
| 32 | * {@link BluetoothProfile#STATE_CONNECTED} |
| 33 | */ |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 34 | public void onConnectionStateChange(BluetoothGatt gatt, int status, |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 35 | int newState) { |
| 36 | } |
| 37 | |
| 38 | /** |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 39 | * Callback invoked when the list of remote services, characteristics and descriptors |
| 40 | * for the remote device have been updated, ie new services have been discovered. |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 41 | * |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 42 | * @param gatt GATT client invoked {@link BluetoothGatt#discoverServices} |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 43 | * @param status {@link BluetoothGatt#GATT_SUCCESS} if the remote device |
| 44 | * has been explored successfully. |
| 45 | */ |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 46 | public void onServicesDiscovered(BluetoothGatt gatt, int status) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Callback reporting the result of a characteristic read operation. |
| 51 | * |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 52 | * @param gatt GATT client invoked {@link BluetoothGatt#readCharacteristic} |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 53 | * @param characteristic Characteristic that was read from the associated |
| 54 | * remote device. |
| 55 | * @param status {@link BluetoothGatt#GATT_SUCCESS} if the read operation |
| 56 | * was completed successfully. |
| 57 | */ |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 58 | public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 59 | int status) { |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Callback indicating the result of a characteristic write operation. |
| 64 | * |
| 65 | * <p>If this callback is invoked while a reliable write transaction is |
| 66 | * in progress, the value of the characteristic represents the value |
| 67 | * reported by the remote device. An application should compare this |
| 68 | * value to the desired value to be written. If the values don't match, |
| 69 | * the application must abort the reliable write transaction. |
| 70 | * |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 71 | * @param gatt GATT client invoked {@link BluetoothGatt#writeCharacteristic} |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 72 | * @param characteristic Characteristic that was written to the associated |
| 73 | * remote device. |
| 74 | * @param status The result of the write operation |
| 75 | */ |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 76 | public void onCharacteristicWrite(BluetoothGatt gatt, |
| 77 | BluetoothGattCharacteristic characteristic, int status) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Callback triggered as a result of a remote characteristic notification. |
| 82 | * |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 83 | * @param gatt GATT client the characteristic is associated with |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 84 | * @param characteristic Characteristic that has been updated as a result |
| 85 | * of a remote notification event. |
| 86 | */ |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 87 | public void onCharacteristicChanged(BluetoothGatt gatt, |
| 88 | BluetoothGattCharacteristic characteristic) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Callback reporting the result of a descriptor read operation. |
| 93 | * |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 94 | * @param gatt GATT client invoked {@link BluetoothGatt#readDescriptor} |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 95 | * @param descriptor Descriptor that was read from the associated |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 96 | * remote device. |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 97 | * @param status {@link BluetoothGatt#GATT_SUCCESS} if the read operation |
| 98 | * was completed successfully |
| 99 | */ |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 100 | public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, |
| 101 | int status) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Callback indicating the result of a descriptor write operation. |
| 106 | * |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 107 | * @param gatt GATT client invoked {@link BluetoothGatt#writeDescriptor} |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 108 | * @param descriptor Descriptor that was writte to the associated |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 109 | * remote device. |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 110 | * @param status The result of the write operation |
| 111 | */ |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 112 | public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, |
| 113 | int status) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Callback invoked when a reliable write transaction has been completed. |
| 118 | * |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 119 | * @param gatt GATT client invoked {@link BluetoothGatt#executeReliableWrite} |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 120 | * @param status {@link BluetoothGatt#GATT_SUCCESS} if the reliable write |
| 121 | * transaction was executed successfully |
| 122 | */ |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 123 | public void onReliableWriteCompleted(BluetoothGatt gatt, int status) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Callback reporting the RSSI for a remote device connection. |
| 128 | * |
| 129 | * This callback is triggered in response to the |
| 130 | * {@link BluetoothGatt#readRemoteRssi} function. |
| 131 | * |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 132 | * @param gatt GATT client invoked {@link BluetoothGatt#readRemoteRssi} |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 133 | * @param rssi The RSSI value for the remote device |
Matthew Xie | ddf7e47 | 2013-03-01 18:41:02 -0800 | [diff] [blame] | 134 | * @param status {@link BluetoothGatt#GATT_SUCCESS} if the RSSI was read successfully |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 135 | */ |
Matthew Xie | 33ec984 | 2013-04-03 00:29:27 -0700 | [diff] [blame^] | 136 | public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) { |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 137 | } |
| 138 | } |