blob: fc3ffe88bcc6325760104aba27e468f748391c4b [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
19import android.bluetooth.BluetoothDevice;
20
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080021/**
22 * This abstract class is used to implement {@link BluetoothGattServer} callbacks.
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080023 */
24public abstract class BluetoothGattServerCallback {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080025
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 * Indicates whether a local service has been added successfully.
41 *
42 * @param status Returns {@link BluetoothGatt#GATT_SUCCESS} if the service
43 * was added successfully.
44 * @param service The service that has been added
45 */
46 public void onServiceAdded(int status, BluetoothGattService service) {
47 }
48
49 /**
50 * A remote client has requested to read a local characteristic.
51 *
52 * <p>An application must call {@link BluetoothGattServer#sendResponse}
53 * to complete the request.
54 *
55 * @param device The remote device that has requested the read operation
56 * @param requestId The Id of the request
57 * @param offset Offset into the value of the characteristic
58 * @param characteristic Characteristic to be read
59 */
60 public void onCharacteristicReadRequest(BluetoothDevice device, int requestId,
61 int offset, BluetoothGattCharacteristic characteristic) {
62 }
63
64 /**
65 * A remote client has requested to write to a local characteristic.
66 *
67 * <p>An application must call {@link BluetoothGattServer#sendResponse}
68 * to complete the request.
69 *
70 * @param device The remote device that has requested the write operation
71 * @param requestId The Id of the request
72 * @param characteristic Characteristic to be written to.
73 * @param preparedWrite true, if this write operation should be queued for
74 * later execution.
75 * @param responseNeeded true, if the remote device requires a response
76 * @param offset The offset given for the value
77 * @param value The value the client wants to assign to the characteristic
78 */
79 public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId,
Matthew Xieddf7e472013-03-01 18:41:02 -080080 BluetoothGattCharacteristic characteristic,
81 boolean preparedWrite, boolean responseNeeded,
82 int offset, byte[] value) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080083 }
84
85 /**
86 * A remote client has requested to read a local descriptor.
87 *
88 * <p>An application must call {@link BluetoothGattServer#sendResponse}
89 * to complete the request.
90 *
91 * @param device The remote device that has requested the read operation
92 * @param requestId The Id of the request
93 * @param offset Offset into the value of the characteristic
94 * @param descriptor Descriptor to be read
95 */
96 public void onDescriptorReadRequest(BluetoothDevice device, int requestId,
Matthew Xieddf7e472013-03-01 18:41:02 -080097 int offset, BluetoothGattDescriptor descriptor) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080098 }
99
100 /**
101 * A remote client has requested to write to a local descriptor.
102 *
103 * <p>An application must call {@link BluetoothGattServer#sendResponse}
104 * to complete the request.
105 *
106 * @param device The remote device that has requested the write operation
107 * @param requestId The Id of the request
108 * @param descriptor Descriptor to be written to.
109 * @param preparedWrite true, if this write operation should be queued for
110 * later execution.
111 * @param responseNeeded true, if the remote device requires a response
112 * @param offset The offset given for the value
113 * @param value The value the client wants to assign to the descriptor
114 */
115 public void onDescriptorWriteRequest(BluetoothDevice device, int requestId,
Matthew Xieddf7e472013-03-01 18:41:02 -0800116 BluetoothGattDescriptor descriptor,
117 boolean preparedWrite, boolean responseNeeded,
118 int offset, byte[] value) {
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800119 }
120
121 /**
122 * Execute all pending write operations for this device.
123 *
124 * <p>An application must call {@link BluetoothGattServer#sendResponse}
125 * to complete the request.
126 *
127 * @param device The remote device that has requested the write operations
128 * @param requestId The Id of the request
129 * @param execute Whether the pending writes should be executed (true) or
130 * cancelled (false)
131 */
132 public void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute) {
133 }
134}