blob: cf82a3304572ae39e6aa4d0e9c526013e0c6a46a [file] [log] [blame]
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -08001/*
Jakub Pawlowskid64bb882017-03-22 11:22:18 -07002 * Copyright (C) 2017 The Android Open Source Project
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -08003 *
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 */
Jack Hea355e5e2017-08-22 16:06:54 -070022public abstract class BluetoothGattCallback {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080023
24 /**
Jakub Pawlowskid64bb882017-03-22 11:22:18 -070025 * Callback triggered as result of {@link BluetoothGatt#setPreferredPhy}, or as a result of
26 * remote device changing the PHY.
27 *
28 * @param gatt GATT client
Jack Hea355e5e2017-08-22 16:06:54 -070029 * @param txPhy the transmitter PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
30 * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
31 * @param rxPhy the receiver PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
32 * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
33 * @param status Status of the PHY update operation. {@link BluetoothGatt#GATT_SUCCESS} if the
34 * operation succeeds.
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080035 */
Jakub Pawlowski409cee62017-02-02 08:07:12 -080036 public void onPhyUpdate(BluetoothGatt gatt, int txPhy, int rxPhy, int status) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080037 }
38
39 /**
Jakub Pawlowskid64bb882017-03-22 11:22:18 -070040 * Callback triggered as result of {@link BluetoothGatt#readPhy}
41 *
42 * @param gatt GATT client
Jack Hea355e5e2017-08-22 16:06:54 -070043 * @param txPhy the transmitter PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
44 * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
45 * @param rxPhy the receiver PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
46 * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
47 * @param status Status of the PHY read operation. {@link BluetoothGatt#GATT_SUCCESS} if the
48 * operation succeeds.
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080049 */
Jakub Pawlowski409cee62017-02-02 08:07:12 -080050 public void onPhyRead(BluetoothGatt gatt, int txPhy, int rxPhy, int status) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080051 }
52
Jakub Pawlowskid64bb882017-03-22 11:22:18 -070053 /**
54 * Callback indicating when GATT client has connected/disconnected to/from a remote
55 * GATT server.
56 *
57 * @param gatt GATT client
Jack Hea355e5e2017-08-22 16:06:54 -070058 * @param status Status of the connect or disconnect operation. {@link
59 * BluetoothGatt#GATT_SUCCESS} if the operation succeeds.
60 * @param newState Returns the new connection state. Can be one of {@link
61 * BluetoothProfile#STATE_DISCONNECTED} or {@link BluetoothProfile#STATE_CONNECTED}
Jakub Pawlowskid64bb882017-03-22 11:22:18 -070062 */
63 public void onConnectionStateChange(BluetoothGatt gatt, int status,
Jack Hea355e5e2017-08-22 16:06:54 -070064 int newState) {
Jakub Pawlowskid64bb882017-03-22 11:22:18 -070065 }
66
67 /**
68 * Callback invoked when the list of remote services, characteristics and descriptors
69 * for the remote device have been updated, ie new services have been discovered.
70 *
71 * @param gatt GATT client invoked {@link BluetoothGatt#discoverServices}
Jack Hea355e5e2017-08-22 16:06:54 -070072 * @param status {@link BluetoothGatt#GATT_SUCCESS} if the remote device has been explored
73 * successfully.
Jakub Pawlowskid64bb882017-03-22 11:22:18 -070074 */
75 public void onServicesDiscovered(BluetoothGatt gatt, int status) {
76 }
77
78 /**
79 * Callback reporting the result of a characteristic read operation.
80 *
81 * @param gatt GATT client invoked {@link BluetoothGatt#readCharacteristic}
Jack Hea355e5e2017-08-22 16:06:54 -070082 * @param characteristic Characteristic that was read from the associated remote device.
83 * @param status {@link BluetoothGatt#GATT_SUCCESS} if the read operation was completed
84 * successfully.
Jakub Pawlowskid64bb882017-03-22 11:22:18 -070085 */
86 public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic,
Jack Hea355e5e2017-08-22 16:06:54 -070087 int status) {
Jakub Pawlowskid64bb882017-03-22 11:22:18 -070088 }
89
90 /**
91 * Callback indicating the result of a characteristic write operation.
92 *
93 * <p>If this callback is invoked while a reliable write transaction is
94 * in progress, the value of the characteristic represents the value
95 * reported by the remote device. An application should compare this
96 * value to the desired value to be written. If the values don't match,
97 * the application must abort the reliable write transaction.
98 *
99 * @param gatt GATT client invoked {@link BluetoothGatt#writeCharacteristic}
Jack Hea355e5e2017-08-22 16:06:54 -0700100 * @param characteristic Characteristic that was written to the associated remote device.
101 * @param status The result of the write operation {@link BluetoothGatt#GATT_SUCCESS} if the
102 * operation succeeds.
Jakub Pawlowskid64bb882017-03-22 11:22:18 -0700103 */
104 public void onCharacteristicWrite(BluetoothGatt gatt,
Jack Hea355e5e2017-08-22 16:06:54 -0700105 BluetoothGattCharacteristic characteristic, int status) {
Jakub Pawlowskid64bb882017-03-22 11:22:18 -0700106 }
107
108 /**
109 * Callback triggered as a result of a remote characteristic notification.
110 *
111 * @param gatt GATT client the characteristic is associated with
Jack Hea355e5e2017-08-22 16:06:54 -0700112 * @param characteristic Characteristic that has been updated as a result of a remote
113 * notification event.
Jakub Pawlowskid64bb882017-03-22 11:22:18 -0700114 */
115 public void onCharacteristicChanged(BluetoothGatt gatt,
Jack Hea355e5e2017-08-22 16:06:54 -0700116 BluetoothGattCharacteristic characteristic) {
Jakub Pawlowskid64bb882017-03-22 11:22:18 -0700117 }
118
119 /**
120 * Callback reporting the result of a descriptor read operation.
121 *
122 * @param gatt GATT client invoked {@link BluetoothGatt#readDescriptor}
Jack Hea355e5e2017-08-22 16:06:54 -0700123 * @param descriptor Descriptor that was read from the associated remote device.
124 * @param status {@link BluetoothGatt#GATT_SUCCESS} if the read operation was completed
125 * successfully
Jakub Pawlowskid64bb882017-03-22 11:22:18 -0700126 */
127 public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
Jack Hea355e5e2017-08-22 16:06:54 -0700128 int status) {
Jakub Pawlowskid64bb882017-03-22 11:22:18 -0700129 }
130
131 /**
132 * Callback indicating the result of a descriptor write operation.
133 *
134 * @param gatt GATT client invoked {@link BluetoothGatt#writeDescriptor}
Jack Hea355e5e2017-08-22 16:06:54 -0700135 * @param descriptor Descriptor that was writte to the associated remote device.
136 * @param status The result of the write operation {@link BluetoothGatt#GATT_SUCCESS} if the
137 * operation succeeds.
Jakub Pawlowskid64bb882017-03-22 11:22:18 -0700138 */
139 public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
Jack Hea355e5e2017-08-22 16:06:54 -0700140 int status) {
Jakub Pawlowskid64bb882017-03-22 11:22:18 -0700141 }
142
143 /**
144 * Callback invoked when a reliable write transaction has been completed.
145 *
146 * @param gatt GATT client invoked {@link BluetoothGatt#executeReliableWrite}
Jack Hea355e5e2017-08-22 16:06:54 -0700147 * @param status {@link BluetoothGatt#GATT_SUCCESS} if the reliable write transaction was
148 * executed successfully
Jakub Pawlowskid64bb882017-03-22 11:22:18 -0700149 */
150 public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
151 }
152
153 /**
154 * Callback reporting the RSSI for a remote device connection.
155 *
156 * This callback is triggered in response to the
157 * {@link BluetoothGatt#readRemoteRssi} function.
158 *
159 * @param gatt GATT client invoked {@link BluetoothGatt#readRemoteRssi}
160 * @param rssi The RSSI value for the remote device
161 * @param status {@link BluetoothGatt#GATT_SUCCESS} if the RSSI was read successfully
162 */
163 public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
164 }
165
166 /**
167 * Callback indicating the MTU for a given device connection has changed.
168 *
169 * This callback is triggered in response to the
170 * {@link BluetoothGatt#requestMtu} function, or in response to a connection
171 * event.
172 *
173 * @param gatt GATT client invoked {@link BluetoothGatt#requestMtu}
174 * @param mtu The new MTU size
175 * @param status {@link BluetoothGatt#GATT_SUCCESS} if the MTU has been changed successfully
176 */
177 public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
178 }
Jakub Pawlowski326f7b32017-03-23 19:05:55 -0700179
180 /**
181 * Callback indicating the connection parameters were updated.
182 *
183 * @param gatt GATT client involved
Jack Hea355e5e2017-08-22 16:06:54 -0700184 * @param interval Connection interval used on this connection, 1.25ms unit. Valid range is from
185 * 6 (7.5ms) to 3200 (4000ms).
186 * @param latency Slave latency for the connection in number of connection events. Valid range
187 * is from 0 to 499
188 * @param timeout Supervision timeout for this connection, in 10ms unit. Valid range is from 10
189 * (0.1s) to 3200 (32s)
Jakub Pawlowski326f7b32017-03-23 19:05:55 -0700190 * @param status {@link BluetoothGatt#GATT_SUCCESS} if the connection has been updated
Jack Hea355e5e2017-08-22 16:06:54 -0700191 * successfully
Jakub Pawlowski326f7b32017-03-23 19:05:55 -0700192 * @hide
193 */
194 public void onConnectionUpdated(BluetoothGatt gatt, int interval, int latency, int timeout,
Jack Hea355e5e2017-08-22 16:06:54 -0700195 int status) {
Jakub Pawlowski326f7b32017-03-23 19:05:55 -0700196 }
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800197}