BluetoothGattCallback.java revision ddf7e4756c31d0ed90802f98abeaa79df6d16b2a
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
17package android.bluetooth;
18
19import android.bluetooth.BluetoothDevice;
20
21/**
22 * This abstract class is used to implement {@link BluetoothGatt} callbacks.
23 */
24public abstract class BluetoothGattCallback {
25
26    /**
27     * Callback indicating when a remote device has been connected or disconnected.
28     *
29     * @param device Remote device that has been connected or disconnected.
30     * @param status Status of the connect or disconnect operation.
31     * @param newState Returns the new connection state. Can be one of
32     *                  {@link BluetoothProfile#STATE_DISCONNECTED} or
33     *                  {@link BluetoothProfile#STATE_CONNECTED}
34     */
35    public void onConnectionStateChange(BluetoothDevice device, int status,
36                                        int newState) {
37    }
38
39    /**
40     * Callback invoked when the list of remote services, characteristics and descriptors
41     * for the remote device have been updated, ie new services have been discovered.
42     *
43     * @param device Remote device
44     * @param status {@link BluetoothGatt#GATT_SUCCESS} if the remote device
45     *               has been explored successfully.
46     */
47    public void onServicesDiscovered(BluetoothDevice device, int status) {
48    }
49
50    /**
51     * Callback reporting the result of a characteristic read operation.
52     *
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     */
58    public void onCharacteristicRead(BluetoothGattCharacteristic characteristic,
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     *
71     * @param characteristic Characteristic that was written to the associated
72     *                       remote device.
73     * @param status The result of the write operation
74     */
75    public void onCharacteristicWrite(BluetoothGattCharacteristic characteristic,
76                                      int status) {
77    }
78
79    /**
80     * Callback triggered as a result of a remote characteristic notification.
81     *
82     * @param characteristic Characteristic that has been updated as a result
83     *                       of a remote notification event.
84     */
85    public void onCharacteristicChanged(BluetoothGattCharacteristic characteristic) {
86    }
87
88    /**
89     * Callback reporting the result of a descriptor read operation.
90     *
91     * @param descriptor Descriptor that was read from the associated
92     *                   remote device.
93     * @param status {@link BluetoothGatt#GATT_SUCCESS} if the read operation
94     *               was completed successfully
95     */
96    public void onDescriptorRead(BluetoothGattDescriptor descriptor, int status) {
97    }
98
99    /**
100     * Callback indicating the result of a descriptor write operation.
101     *
102     * @param descriptor Descriptor that was writte to the associated
103     *                   remote device.
104     * @param status The result of the write operation
105     */
106    public void onDescriptorWrite(BluetoothGattDescriptor descriptor, int status) {
107    }
108
109    /**
110     * Callback invoked when a reliable write transaction has been completed.
111     *
112     * @param device Remote device
113     * @param status {@link BluetoothGatt#GATT_SUCCESS} if the reliable write
114     *               transaction was executed successfully
115     */
116    public void onReliableWriteCompleted(BluetoothDevice device, int status) {
117    }
118
119    /**
120     * Callback reporting the RSSI for a remote device connection.
121     *
122     * This callback is triggered in response to the
123     * {@link BluetoothGatt#readRemoteRssi} function.
124     *
125     * @param device Identifies the remote device
126     * @param rssi The RSSI value for the remote device
127     * @param status {@link BluetoothGatt#GATT_SUCCESS} if the RSSI was read successfully
128     */
129    public void onReadRemoteRssi(BluetoothDevice device, int rssi, int status) {
130    }
131}
132