blob: 2259c1eff5cf922102db5eead2f443b106b0bcec [file] [log] [blame]
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -08001/*
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
17package android.bluetooth;
18
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080019/**
20 * This abstract class is used to implement {@link BluetoothGatt} callbacks.
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080021 */
22public abstract class BluetoothGattCallback {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080023
24 /**
Matthew Xie33ec9842013-04-03 00:29:27 -070025 * Callback indicating when GATT client has connected/disconnected to/from a remote
26 * GATT server.
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080027 *
Matthew Xie33ec9842013-04-03 00:29:27 -070028 * @param gatt GATT client
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080029 * @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 Xie33ec9842013-04-03 00:29:27 -070034 public void onConnectionStateChange(BluetoothGatt gatt, int status,
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080035 int newState) {
36 }
37
38 /**
Matthew Xieddf7e472013-03-01 18:41:02 -080039 * 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 Batta99081122013-02-05 15:28:33 -080041 *
Matthew Xie33ec9842013-04-03 00:29:27 -070042 * @param gatt GATT client invoked {@link BluetoothGatt#discoverServices}
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080043 * @param status {@link BluetoothGatt#GATT_SUCCESS} if the remote device
44 * has been explored successfully.
45 */
Matthew Xie33ec9842013-04-03 00:29:27 -070046 public void onServicesDiscovered(BluetoothGatt gatt, int status) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080047 }
48
49 /**
50 * Callback reporting the result of a characteristic read operation.
51 *
Matthew Xie33ec9842013-04-03 00:29:27 -070052 * @param gatt GATT client invoked {@link BluetoothGatt#readCharacteristic}
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080053 * @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 Xie33ec9842013-04-03 00:29:27 -070058 public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic,
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080059 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 Xie33ec9842013-04-03 00:29:27 -070071 * @param gatt GATT client invoked {@link BluetoothGatt#writeCharacteristic}
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080072 * @param characteristic Characteristic that was written to the associated
73 * remote device.
74 * @param status The result of the write operation
75 */
Matthew Xie33ec9842013-04-03 00:29:27 -070076 public void onCharacteristicWrite(BluetoothGatt gatt,
77 BluetoothGattCharacteristic characteristic, int status) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080078 }
79
80 /**
81 * Callback triggered as a result of a remote characteristic notification.
82 *
Matthew Xie33ec9842013-04-03 00:29:27 -070083 * @param gatt GATT client the characteristic is associated with
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080084 * @param characteristic Characteristic that has been updated as a result
85 * of a remote notification event.
86 */
Matthew Xie33ec9842013-04-03 00:29:27 -070087 public void onCharacteristicChanged(BluetoothGatt gatt,
88 BluetoothGattCharacteristic characteristic) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080089 }
90
91 /**
92 * Callback reporting the result of a descriptor read operation.
93 *
Matthew Xie33ec9842013-04-03 00:29:27 -070094 * @param gatt GATT client invoked {@link BluetoothGatt#readDescriptor}
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080095 * @param descriptor Descriptor that was read from the associated
Matthew Xieddf7e472013-03-01 18:41:02 -080096 * remote device.
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080097 * @param status {@link BluetoothGatt#GATT_SUCCESS} if the read operation
98 * was completed successfully
99 */
Matthew Xie33ec9842013-04-03 00:29:27 -0700100 public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
101 int status) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800102 }
103
104 /**
105 * Callback indicating the result of a descriptor write operation.
106 *
Matthew Xie33ec9842013-04-03 00:29:27 -0700107 * @param gatt GATT client invoked {@link BluetoothGatt#writeDescriptor}
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800108 * @param descriptor Descriptor that was writte to the associated
Matthew Xieddf7e472013-03-01 18:41:02 -0800109 * remote device.
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800110 * @param status The result of the write operation
111 */
Matthew Xie33ec9842013-04-03 00:29:27 -0700112 public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
113 int status) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800114 }
115
116 /**
117 * Callback invoked when a reliable write transaction has been completed.
118 *
Matthew Xie33ec9842013-04-03 00:29:27 -0700119 * @param gatt GATT client invoked {@link BluetoothGatt#executeReliableWrite}
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800120 * @param status {@link BluetoothGatt#GATT_SUCCESS} if the reliable write
121 * transaction was executed successfully
122 */
Matthew Xie33ec9842013-04-03 00:29:27 -0700123 public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800124 }
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 Xie33ec9842013-04-03 00:29:27 -0700132 * @param gatt GATT client invoked {@link BluetoothGatt#readRemoteRssi}
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800133 * @param rssi The RSSI value for the remote device
Matthew Xieddf7e472013-03-01 18:41:02 -0800134 * @param status {@link BluetoothGatt#GATT_SUCCESS} if the RSSI was read successfully
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800135 */
Matthew Xie33ec9842013-04-03 00:29:27 -0700136 public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800137 }
138}